]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk1/spinctrl.cpp
VTK wrapper of vtkRenderWindow for wxPython. Tested on MSW so far.
[wxWidgets.git] / src / gtk1 / spinctrl.cpp
index 77cc2b8fe5f299f112f1436ee59ef10ff453a14c..cf1e437da661b143a10be1d71e3087fb7fa1f6bb 100644 (file)
@@ -85,6 +85,10 @@ static void gtk_spinctrl_callback( GtkWidget *WXUNUSED(widget), wxSpinCtrl *win
 
 IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl,wxControl)
 
+BEGIN_EVENT_TABLE(wxSpinCtrl, wxControl)
+    EVT_CHAR(wxSpinCtrl::OnChar)
+END_EVENT_TABLE()
+
 bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
                         const wxString& value,
                         const wxPoint& pos,  const wxSize& size,
@@ -93,6 +97,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
                         const wxString& name)
 {
     m_needParent = TRUE;
+    m_acceptsFocus = TRUE;
 
     wxSize new_size = size;
     if (new_size.y == -1)
@@ -111,7 +116,8 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
 
     m_widget = gtk_spin_button_new( m_adjust, 1, 0 );
 
-    gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget), (m_windowStyle & wxSP_WRAP) );
+    gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget),
+                              (int)(m_windowStyle & wxSP_WRAP) );
 
     gtk_signal_connect( GTK_OBJECT (m_adjust),
                         "value_changed",
@@ -205,6 +211,27 @@ void wxSpinCtrl::SetRange(int minVal, int maxVal)
     SetFocus();
 }
 
+void wxSpinCtrl::OnChar( wxKeyEvent &event )
+{
+    wxCHECK_RET( m_widget != NULL, wxT("invalid spin ctrl") );
+
+    if (event.KeyCode() == WXK_RETURN)
+    {
+        wxWindow *top_frame = m_parent;
+        while (top_frame->GetParent() && !(top_frame->GetParent()->m_isFrame))
+            top_frame = top_frame->GetParent();
+       GtkWindow *window = GTK_WINDOW(top_frame->m_widget);
+       
+       if (window->default_widget)
+        {
+            gtk_widget_activate (window->default_widget);
+           return;
+       }
+    }
+
+    event.Skip();
+}
+
 bool wxSpinCtrl::IsOwnGtkWindow( GdkWindow *window )
 {
     return GTK_SPIN_BUTTON(m_widget)->panel == window;