]> git.saurik.com Git - wxWidgets.git/commitdiff
Added test for default action (button normally)
authorRobert Roebling <robert@roebling.de>
Tue, 19 Feb 2002 21:48:03 +0000 (21:48 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 19 Feb 2002 21:48:03 +0000 (21:48 +0000)
    to combo box when hittinh return. In a normal
    Find&Replace dialog, hitting enter in one of
    the two fields will usually mean "OK".
  Corrected the same test in wxTextCtrl.
  Removed some debug code.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14311 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/combobox.cpp
src/gtk/textctrl.cpp
src/gtk/window.cpp
src/gtk1/combobox.cpp
src/gtk1/textctrl.cpp
src/gtk1/window.cpp

index 326381bcb41edc77bce20cb0dac4475a4dc9d572..de35777f0b8bc2682090eac4e64d887837df7366 100644 (file)
@@ -615,7 +615,26 @@ void wxComboBox::OnChar( wxKeyEvent &event )
                 event.SetEventObject( this );
                 GetEventHandler()->ProcessEvent( event );
             }
-            //else: do nothing, this will open the listbox
+            else
+            {
+                // This will invoke the dialog default action, such
+                // as the clicking the default button.
+    
+                wxWindow *top_frame = m_parent;
+                while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
+                top_frame = top_frame->GetParent();
+        
+                if (top_frame && GTK_IS_WINDOW(top_frame->m_widget))
+                {
+                    GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
+
+                    if (window->default_widget)
+                    {
+                        gtk_widget_activate (window->default_widget);
+                        return;
+                    }
+                }
+            }
         }
     }
 
index 6c37c6636ac42b8c054524fa27eaa063965066af..48cb8c1e774f126babfdbbe9de5ccb291b6348df 100644 (file)
@@ -964,15 +964,22 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event )
 
     if ((key_event.KeyCode() == WXK_RETURN) && !(m_windowStyle & wxTE_MULTILINE))
     {
+        // This will invoke the dialog default action, such
+        // as the clicking the default button.
+    
         wxWindow *top_frame = m_parent;
         while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
             top_frame = top_frame->GetParent();
-        GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
-
-        if (window->default_widget)
+        
+        if (top_frame && GTK_IS_WINDOW(top_frame->m_widget))
         {
-            gtk_widget_activate (window->default_widget);
-            return;
+            GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
+
+            if (window->default_widget)
+            {
+                gtk_widget_activate (window->default_widget);
+                return;
+            }
         }
     }
 
index 30fae11783dc31138d400db68cabbb74b8aaa946..b2941feb0a3e4cf27b0fa462099cb00df48acae0 100644 (file)
@@ -1640,7 +1640,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
     g_focusWindowLast =
     g_focusWindow = win;
 
-#if 1
+#if 0
     wxPrintf( "OnSetFocus from " );
     if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
         wxPrintf( win->GetClassInfo()->GetClassName() );
index 326381bcb41edc77bce20cb0dac4475a4dc9d572..de35777f0b8bc2682090eac4e64d887837df7366 100644 (file)
@@ -615,7 +615,26 @@ void wxComboBox::OnChar( wxKeyEvent &event )
                 event.SetEventObject( this );
                 GetEventHandler()->ProcessEvent( event );
             }
-            //else: do nothing, this will open the listbox
+            else
+            {
+                // This will invoke the dialog default action, such
+                // as the clicking the default button.
+    
+                wxWindow *top_frame = m_parent;
+                while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
+                top_frame = top_frame->GetParent();
+        
+                if (top_frame && GTK_IS_WINDOW(top_frame->m_widget))
+                {
+                    GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
+
+                    if (window->default_widget)
+                    {
+                        gtk_widget_activate (window->default_widget);
+                        return;
+                    }
+                }
+            }
         }
     }
 
index 6c37c6636ac42b8c054524fa27eaa063965066af..48cb8c1e774f126babfdbbe9de5ccb291b6348df 100644 (file)
@@ -964,15 +964,22 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event )
 
     if ((key_event.KeyCode() == WXK_RETURN) && !(m_windowStyle & wxTE_MULTILINE))
     {
+        // This will invoke the dialog default action, such
+        // as the clicking the default button.
+    
         wxWindow *top_frame = m_parent;
         while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
             top_frame = top_frame->GetParent();
-        GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
-
-        if (window->default_widget)
+        
+        if (top_frame && GTK_IS_WINDOW(top_frame->m_widget))
         {
-            gtk_widget_activate (window->default_widget);
-            return;
+            GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
+
+            if (window->default_widget)
+            {
+                gtk_widget_activate (window->default_widget);
+                return;
+            }
         }
     }
 
index 30fae11783dc31138d400db68cabbb74b8aaa946..b2941feb0a3e4cf27b0fa462099cb00df48acae0 100644 (file)
@@ -1640,7 +1640,7 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget,
     g_focusWindowLast =
     g_focusWindow = win;
 
-#if 1
+#if 0
     wxPrintf( "OnSetFocus from " );
     if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
         wxPrintf( win->GetClassInfo()->GetClassName() );