Only send keypress events to focus widget, not its parents

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48707 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2007-09-15 10:28:35 +00:00
parent 2528a5f80c
commit a53f323b1f

View File

@@ -989,6 +989,11 @@ gtk_window_key_press_callback( GtkWidget *widget,
if (g_blockEventsOnDrag) if (g_blockEventsOnDrag)
return FALSE; return FALSE;
// GTK+ sends keypress events to the focus widget and then
// to all its parent and grandparent widget. We only want
// the key events from the focus widget.
if (!GTK_WIDGET_HAS_FOCUS(widget))
return FALSE;
wxKeyEvent event( wxEVT_KEY_DOWN ); wxKeyEvent event( wxEVT_KEY_DOWN );
bool ret = false; bool ret = false;
@@ -3177,6 +3182,7 @@ bool wxWindowGTK::GTKSetDelayedFocusIfNeeded()
void wxWindowGTK::SetFocus() void wxWindowGTK::SetFocus()
{ {
wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
if ( m_hasFocus ) if ( m_hasFocus )
{ {
// don't do anything if we already have focus // don't do anything if we already have focus