]> git.saurik.com Git - wxWidgets.git/commitdiff
GtkIMContext must be the first to process keypress events, otherwise you won't be...
authorVáclav Slavík <vslavik@fastmail.fm>
Thu, 24 Jun 2004 20:27:49 +0000 (20:27 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Thu, 24 Jun 2004 20:27:49 +0000 (20:27 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28014 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/window.cpp
src/gtk1/window.cpp

index e471db7e9fbaa9c76ca3dd9970c1ca239d3a0e43..e805789afc1399c9208392c92d730341a4b55370 100644 (file)
@@ -1097,6 +1097,17 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
     if (g_blockEventsOnDrag)
         return FALSE;
 
+#ifdef __WXGTK20__
+    if (win->m_imContext)
+    {
+        // In GTK 2.0, we need to hand over the key event to an input method
+        // and the IM will emit a "commit" event containing the actual utf8
+        // character.  In that case the EVT_CHAR events will be sent from
+        // there.
+        if ( gtk_im_context_filter_keypress(win->m_imContext, gdk_event) )
+            return TRUE;
+    }
+#endif
 
     wxKeyEvent event( wxEVT_KEY_DOWN );
     if ( !wxTranslateGTKKeyEventToWx(event, win, gdk_event) )
@@ -1134,56 +1145,41 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
     {
         long key_code;
         KeySym keysym = gdk_event->keyval;
-#ifdef __WXGTK20__
-        // In GTK 2.0, we need to hand over the key event to an input method
-        // and the IM will emit a "commit" event containing the actual utf8
-        // character.  In that case the EVT_CHAR events will be sent from
-        // there.  But only do it this way for non-KeySym keys.
-        key_code = wxTranslateKeySymToWXKey(gdk_event->keyval, FALSE /* isChar */);
-        if ( !key_code && win->m_imContext )
-        {
-            gtk_im_context_filter_keypress(win->m_imContext, gdk_event );
-            ret = TRUE;
-        }
-        else
-#endif
+        // Find key code for EVT_CHAR and EVT_CHAR_HOOK events
+        key_code = wxTranslateKeySymToWXKey(keysym, TRUE /* isChar */);
+        if ( !key_code )
         {
-            // Find key code for EVT_CHAR and EVT_CHAR_HOOK events
-            key_code = wxTranslateKeySymToWXKey(keysym, TRUE /* isChar */);
-            if ( !key_code )
+            if ( gdk_event->length == 1 )
             {
-                if ( gdk_event->length == 1 )
-                {
-                    key_code = (unsigned char)gdk_event->string[0];
-                }
-                else if ( wxIsAsciiKeysym(keysym) )
-                {
-                    // ASCII key
-                    key_code = (unsigned char)keysym;
-                }
+                key_code = (unsigned char)gdk_event->string[0];
             }
-
-            if ( key_code )
+            else if ( wxIsAsciiKeysym(keysym) )
             {
-                wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code);
+                // ASCII key
+                key_code = (unsigned char)keysym;
+            }
+        }
+
+        if ( key_code )
+        {
+            wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code);
 
-                event.m_keyCode = key_code;
+            event.m_keyCode = key_code;
 
-                // Implement OnCharHook by checking ancesteror top level windows
-                wxWindow *parent = win;
-                while (parent && !parent->IsTopLevel())
-                    parent = parent->GetParent();
-                if (parent)
-                {
-                    event.SetEventType( wxEVT_CHAR_HOOK );
-                    ret = parent->GetEventHandler()->ProcessEvent( event );
-                }
+            // Implement OnCharHook by checking ancesteror top level windows
+            wxWindow *parent = win;
+            while (parent && !parent->IsTopLevel())
+                parent = parent->GetParent();
+            if (parent)
+            {
+                event.SetEventType( wxEVT_CHAR_HOOK );
+                ret = parent->GetEventHandler()->ProcessEvent( event );
+            }
 
-                if (!ret)
-                {
-                    event.SetEventType(wxEVT_CHAR);
-                    ret = win->GetEventHandler()->ProcessEvent( event );
-                }
+            if (!ret)
+            {
+                event.SetEventType(wxEVT_CHAR);
+                ret = win->GetEventHandler()->ProcessEvent( event );
             }
         }
     }
index e471db7e9fbaa9c76ca3dd9970c1ca239d3a0e43..e805789afc1399c9208392c92d730341a4b55370 100644 (file)
@@ -1097,6 +1097,17 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
     if (g_blockEventsOnDrag)
         return FALSE;
 
+#ifdef __WXGTK20__
+    if (win->m_imContext)
+    {
+        // In GTK 2.0, we need to hand over the key event to an input method
+        // and the IM will emit a "commit" event containing the actual utf8
+        // character.  In that case the EVT_CHAR events will be sent from
+        // there.
+        if ( gtk_im_context_filter_keypress(win->m_imContext, gdk_event) )
+            return TRUE;
+    }
+#endif
 
     wxKeyEvent event( wxEVT_KEY_DOWN );
     if ( !wxTranslateGTKKeyEventToWx(event, win, gdk_event) )
@@ -1134,56 +1145,41 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
     {
         long key_code;
         KeySym keysym = gdk_event->keyval;
-#ifdef __WXGTK20__
-        // In GTK 2.0, we need to hand over the key event to an input method
-        // and the IM will emit a "commit" event containing the actual utf8
-        // character.  In that case the EVT_CHAR events will be sent from
-        // there.  But only do it this way for non-KeySym keys.
-        key_code = wxTranslateKeySymToWXKey(gdk_event->keyval, FALSE /* isChar */);
-        if ( !key_code && win->m_imContext )
-        {
-            gtk_im_context_filter_keypress(win->m_imContext, gdk_event );
-            ret = TRUE;
-        }
-        else
-#endif
+        // Find key code for EVT_CHAR and EVT_CHAR_HOOK events
+        key_code = wxTranslateKeySymToWXKey(keysym, TRUE /* isChar */);
+        if ( !key_code )
         {
-            // Find key code for EVT_CHAR and EVT_CHAR_HOOK events
-            key_code = wxTranslateKeySymToWXKey(keysym, TRUE /* isChar */);
-            if ( !key_code )
+            if ( gdk_event->length == 1 )
             {
-                if ( gdk_event->length == 1 )
-                {
-                    key_code = (unsigned char)gdk_event->string[0];
-                }
-                else if ( wxIsAsciiKeysym(keysym) )
-                {
-                    // ASCII key
-                    key_code = (unsigned char)keysym;
-                }
+                key_code = (unsigned char)gdk_event->string[0];
             }
-
-            if ( key_code )
+            else if ( wxIsAsciiKeysym(keysym) )
             {
-                wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code);
+                // ASCII key
+                key_code = (unsigned char)keysym;
+            }
+        }
+
+        if ( key_code )
+        {
+            wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code);
 
-                event.m_keyCode = key_code;
+            event.m_keyCode = key_code;
 
-                // Implement OnCharHook by checking ancesteror top level windows
-                wxWindow *parent = win;
-                while (parent && !parent->IsTopLevel())
-                    parent = parent->GetParent();
-                if (parent)
-                {
-                    event.SetEventType( wxEVT_CHAR_HOOK );
-                    ret = parent->GetEventHandler()->ProcessEvent( event );
-                }
+            // Implement OnCharHook by checking ancesteror top level windows
+            wxWindow *parent = win;
+            while (parent && !parent->IsTopLevel())
+                parent = parent->GetParent();
+            if (parent)
+            {
+                event.SetEventType( wxEVT_CHAR_HOOK );
+                ret = parent->GetEventHandler()->ProcessEvent( event );
+            }
 
-                if (!ret)
-                {
-                    event.SetEventType(wxEVT_CHAR);
-                    ret = win->GetEventHandler()->ProcessEvent( event );
-                }
+            if (!ret)
+            {
+                event.SetEventType(wxEVT_CHAR);
+                ret = win->GetEventHandler()->ProcessEvent( event );
             }
         }
     }