if (g_blockEventsOnDrag)
return FALSE;
- wxKeyEvent event( wxEVT_KEY_DOWN );
+ bool ret = FALSE;
+
+ wxKeyEvent event( wxEVT_CHAR_HOOK );
if ( !wxTranslateGTKKeyEventToWx(event, win, gdk_event) )
{
// unknown key pressed, ignore (the event would be useless anyhow)
return FALSE;
}
- bool ret = win->GetEventHandler()->ProcessEvent( event );
+ // Implement wxFrame::OnCharHook by checking ancestor.
+ wxWindow *parent = win;
+ while (parent && !parent->IsTopLevel())
+ parent = parent->GetParent();
+
+ if (parent)
+ ret = parent->GetEventHandler()->ProcessEvent( event );
+
+ if (!ret)
+ {
+ event.SetEventType(wxEVT_KEY_DOWN);
+ ret = win->GetEventHandler()->ProcessEvent( event );
+ }
#if wxUSE_ACCEL
if (!ret)
/* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
will only be sent if it is not in an accelerator table. */
- if ( !ret )
+ if (!ret)
{
KeySym keysym = gdk_event->keyval;
long key_code = wxTranslateKeySymToWXKey(keysym, TRUE /* isChar */);
return (wxWindow *)g_focusWindow;
}
+//-----------------------------------------------------------------------------
+// "destroy" event
+//-----------------------------------------------------------------------------
+
+static void gtk_window_destroy_callback( GtkWidget* widget, wxWindow *win )
+{
+ wxWindowDestroyEvent event(win);
+ win->GetEventHandler()->ProcessEvent(event);
+}
+
//-----------------------------------------------------------------------------
// "realize" from m_widget
//-----------------------------------------------------------------------------
gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event",
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "destroy",
+ GTK_SIGNAL_FUNC(gtk_window_destroy_callback), (gpointer)this );
}
bool wxWindowGTK::Destroy()
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
-
+
// No scrolling requested.
if ((dx == 0) && (dy == 0)) return;
if (g_blockEventsOnDrag)
return FALSE;
- wxKeyEvent event( wxEVT_KEY_DOWN );
+ bool ret = FALSE;
+
+ wxKeyEvent event( wxEVT_CHAR_HOOK );
if ( !wxTranslateGTKKeyEventToWx(event, win, gdk_event) )
{
// unknown key pressed, ignore (the event would be useless anyhow)
return FALSE;
}
- bool ret = win->GetEventHandler()->ProcessEvent( event );
+ // Implement wxFrame::OnCharHook by checking ancestor.
+ wxWindow *parent = win;
+ while (parent && !parent->IsTopLevel())
+ parent = parent->GetParent();
+
+ if (parent)
+ ret = parent->GetEventHandler()->ProcessEvent( event );
+
+ if (!ret)
+ {
+ event.SetEventType(wxEVT_KEY_DOWN);
+ ret = win->GetEventHandler()->ProcessEvent( event );
+ }
#if wxUSE_ACCEL
if (!ret)
/* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
will only be sent if it is not in an accelerator table. */
- if ( !ret )
+ if (!ret)
{
KeySym keysym = gdk_event->keyval;
long key_code = wxTranslateKeySymToWXKey(keysym, TRUE /* isChar */);
return (wxWindow *)g_focusWindow;
}
+//-----------------------------------------------------------------------------
+// "destroy" event
+//-----------------------------------------------------------------------------
+
+static void gtk_window_destroy_callback( GtkWidget* widget, wxWindow *win )
+{
+ wxWindowDestroyEvent event(win);
+ win->GetEventHandler()->ProcessEvent(event);
+}
+
//-----------------------------------------------------------------------------
// "realize" from m_widget
//-----------------------------------------------------------------------------
gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event",
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
+
+ gtk_signal_connect( GTK_OBJECT(widget), "destroy",
+ GTK_SIGNAL_FUNC(gtk_window_destroy_callback), (gpointer)this );
}
bool wxWindowGTK::Destroy()
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") );
-
+
// No scrolling requested.
if ((dx == 0) && (dy == 0)) return;