ESC Key
racoon
xracoonx at gmx.de
Sun Jan 22 15:36:14 UTC 2023
On 2023-01-22 13:44, Daniel wrote:
> On 2023-01-22 10:25, Evan Langlois wrote:
>> Is there some way to reconfigure LyX to not have ESC cancel a dialog
>> or at least ask me first? I tried to remove the keybinding for esc in
>> the preferences, but that didn't help. The issue is that I use vi, so
>> when editing the preamble my hand just hits the esc key to save out of
>> habit. All my changes are then gone without a "Hey you changed stuff!
>> Are you sure?"
>
> I don't think there is a way. And I am not sure it is a common enough
> case to allow for a preference or so.
>
> But it sounds like you would be satisfied with LyX asking whether to
> discard changes made to the preamble before cancelling the dialog. I
> think that is generally a good idea. After all, it is like editing your
> document where we also don't just let the user close the window without
> asking.
>
> Daniel
Attached is a simple patch that avoids the dialog being closed when the
Esc key is pressed. The patch presupposes the source code patch to
ticket #12577 (https://www.lyx.org/trac/ticket/12577).
As suggested above, at least additionally, there should also be a
warning when source codes where changed whether the dialog should be
closed. But that is not implemented with this patch.
Daniel
-------------- next part --------------
From 80748b0a03441ca6f959d9776eef8a092aef644c Mon Sep 17 00:00:00 2001
From: Daniel Ramoeller <d.lyx at web.de>
Date: Sun, 22 Jan 2023 16:31:53 +0100
Subject: [PATCH 2/2] When editing source code, prevent Escape key
When editing source code, e.g. the local layout or the LaTeX preamble, pressing the Esc key leads to the dialog being closed. This is prevented by the patch.
---
src/frontends/qt/GuiSourceEdit.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/frontends/qt/GuiSourceEdit.cpp b/src/frontends/qt/GuiSourceEdit.cpp
index 9b008a5d03..e451688752 100644
--- a/src/frontends/qt/GuiSourceEdit.cpp
+++ b/src/frontends/qt/GuiSourceEdit.cpp
@@ -300,7 +300,9 @@ void GuiSourceEdit::keyPressEvent(QKeyEvent *event)
modifyMarkerInSel("\t", REMOVE);
else if (event->key() == Qt::Key_Return)
newLineWithInheritedIndentation();
- else
+ else if (event->key() == Qt::Key_Escape) {
+ // Ignore the ESC key so that the dialog isn't closed
+ } else
// Call base class for other events
QTextEdit::keyPressEvent(event);
}
--
2.24.3 (Apple Git-128)
More information about the lyx-devel
mailing list