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,
const wxString& name)
{
m_needParent = TRUE;
+ m_acceptsFocus = TRUE;
wxSize new_size = size;
if (new_size.y == -1)
else
{
// invalid number - set text as is (wxMSW compatible)
- gtk_entry_set_text( GTK_ENTRY(m_widget), value.c_str() );
+ gtk_entry_set_text( GTK_ENTRY(m_widget), value.mbc_str() );
}
}
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;