aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2000-11-08 11:01:31 +0000
committernyamatongwe <devnull@localhost>2000-11-08 11:01:31 +0000
commit6fc5151e4fdd7b1f3bc232f5c0ce405aabae1ea4 (patch)
treed58bbb6464ff6289407fb2cccca039f65b36b31e
parent4eb5bc53a4bf2484b881750db2345847f54f8383 (diff)
downloadscintilla-mirror-6fc5151e4fdd7b1f3bc232f5c0ce405aabae1ea4.tar.gz
Changed keystroke handling so that GTK+ stops keys that are mapped to
commands which allows them to propogate up to containers rather than requiring explicit propogation.
-rw-r--r--gtk/ScintillaGTK.cxx15
-rw-r--r--src/Editor.cxx11
-rw-r--r--src/Editor.h2
3 files changed, 18 insertions, 10 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index b0130a793..615c79633 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -306,10 +306,10 @@ void ScintillaGTK::Initialise() {
// Using "after" connect to avoid main window using cursor keys
// to move focus.
- //gtk_signal_connect(GTK_OBJECT(wMain), "key_press_event",
- // GtkSignalFunc(key_event), this);
- gtk_signal_connect_after(GTK_OBJECT(wMain.GetID()), "key_press_event",
- GtkSignalFunc(KeyPress), this);
+ gtk_signal_connect(GTK_OBJECT(wMain.GetID()), "key_press_event",
+ GtkSignalFunc(KeyPress), this);
+ //gtk_signal_connect_after(GTK_OBJECT(wMain.GetID()), "key_press_event",
+ // GtkSignalFunc(KeyPress), this);
gtk_signal_connect(GTK_OBJECT(wMain.GetID()), "key_release_event",
GtkSignalFunc(KeyRelease), this);
@@ -994,7 +994,7 @@ static int KeyTranslate(int keyIn) {
}
}
-gint ScintillaGTK::KeyPress(GtkWidget *, GdkEventKey *event, ScintillaGTK *sciThis) {
+gint ScintillaGTK::KeyPress(GtkWidget *w, GdkEventKey *event, ScintillaGTK *sciThis) {
//Platform::DebugPrintf("SC-key: %d %x %x\n",event->keyval, event->state, GTK_WIDGET_FLAG(sciThis));
bool shift = event->state & GDK_SHIFT_MASK;
bool ctrl = event->state & GDK_CONTROL_MASK;
@@ -1007,8 +1007,11 @@ gint ScintillaGTK::KeyPress(GtkWidget *, GdkEventKey *event, ScintillaGTK *sciTh
else
key = KeyTranslate(key);
- sciThis->KeyDown(key, shift, ctrl, alt);
+ bool consumed = false;
+ sciThis->KeyDown(key, shift, ctrl, alt, &consumed);
//Platform::DebugPrintf("SK-key: %d %x %x\n",event->keyval, event->state, GTK_WIDGET_FLAGS(widget));
+ if (consumed)
+ gtk_signal_emit_stop_by_name(GTK_OBJECT(w), "key_press_event");
return TRUE;
}
diff --git a/src/Editor.cxx b/src/Editor.cxx
index dd4551735..3761154f3 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -2296,14 +2296,19 @@ int Editor::KeyDefault(int, int) {
return 0;
}
-int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt) {
+int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) {
int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
(alt ? SCI_ALT : 0);
int msg = kmap.Find(key, modifiers);
- if (msg)
+ if (msg) {
+ if (consumed)
+ *consumed = true;
return WndProc(msg, 0, 0);
- else
+ } else {
+ if (consumed)
+ *consumed = false;
return KeyDefault(key, modifiers);
+ }
}
void Editor::SetWhitespaceVisible(int view) {
diff --git a/src/Editor.h b/src/Editor.h
index 1d0b47c56..3733aedc1 100644
--- a/src/Editor.h
+++ b/src/Editor.h
@@ -258,7 +258,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
virtual void CancelModes();
virtual int KeyCommand(unsigned int iMessage);
virtual int KeyDefault(int /* key */, int /*modifiers*/);
- int KeyDown(int key, bool shift, bool ctrl, bool alt);
+ int KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed=0);
int GetWhitespaceVisible();
void SetWhitespaceVisible(int view);