Fixed lost focus events in wxListBox.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29935 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -51,6 +51,8 @@ extern bool g_blockEventsOnDrag;
|
|||||||
extern bool g_blockEventsOnScroll;
|
extern bool g_blockEventsOnScroll;
|
||||||
extern wxCursor g_globalCursor;
|
extern wxCursor g_globalCursor;
|
||||||
extern wxWindowGTK *g_delayedFocus;
|
extern wxWindowGTK *g_delayedFocus;
|
||||||
|
extern wxWindowGTK *g_focusWindow;
|
||||||
|
extern wxWindowGTK *g_focusWindowLast;
|
||||||
|
|
||||||
static bool g_hasDoubleClicked = FALSE;
|
static bool g_hasDoubleClicked = FALSE;
|
||||||
|
|
||||||
@@ -87,6 +89,68 @@ extern "C" gint wxlistbox_idle_callback( gpointer gdata )
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// "focus_in_event"
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static gint gtk_listitem_focus_in_callback( GtkWidget *widget,
|
||||||
|
GdkEvent *WXUNUSED(event),
|
||||||
|
wxWindow *win )
|
||||||
|
{
|
||||||
|
if (g_isIdle)
|
||||||
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
|
g_focusWindowLast =
|
||||||
|
g_focusWindow = win;
|
||||||
|
|
||||||
|
// does the window itself think that it has the focus?
|
||||||
|
if ( !win->m_hasFocus )
|
||||||
|
{
|
||||||
|
// not yet, notify it
|
||||||
|
win->m_hasFocus = TRUE;
|
||||||
|
|
||||||
|
wxChildFocusEvent eventChildFocus(win);
|
||||||
|
(void)win->GetEventHandler()->ProcessEvent(eventChildFocus);
|
||||||
|
|
||||||
|
wxFocusEvent eventFocus(wxEVT_SET_FOCUS, win->GetId());
|
||||||
|
eventFocus.SetEventObject(win);
|
||||||
|
|
||||||
|
(void)win->GetEventHandler()->ProcessEvent(eventFocus);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// "focus_out_event"
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static gint gtk_listitem_focus_out_callback( GtkWidget *widget, GdkEventFocus *gdk_event, wxWindowGTK *win )
|
||||||
|
{
|
||||||
|
if (g_isIdle)
|
||||||
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
|
g_focusWindow = (wxWindowGTK *)NULL;
|
||||||
|
|
||||||
|
// don't send the window a kill focus event if it thinks that it doesn't
|
||||||
|
// have focus already
|
||||||
|
if ( win->m_hasFocus )
|
||||||
|
{
|
||||||
|
win->m_hasFocus = FALSE;
|
||||||
|
|
||||||
|
wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
|
||||||
|
event.SetEventObject( win );
|
||||||
|
|
||||||
|
// even if we did process the event in wx code, still let GTK itself
|
||||||
|
// process it too as otherwise bad things happen, especially in GTK2
|
||||||
|
// where the text control simply aborts the program if it doesn't get
|
||||||
|
// the matching focus out event
|
||||||
|
(void)win->GetEventHandler()->ProcessEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// "button_release_event"
|
// "button_release_event"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -607,6 +671,14 @@ void wxListBox::GtkAddItem( const wxString &item, int pos )
|
|||||||
(GtkSignalFunc)gtk_listbox_key_press_callback,
|
(GtkSignalFunc)gtk_listbox_key_press_callback,
|
||||||
(gpointer)this );
|
(gpointer)this );
|
||||||
|
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(list_item), "focus_in_event",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_listitem_focus_in_callback), (gpointer)this );
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(list_item), "focus_out_event",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_listitem_focus_out_callback), (gpointer)this );
|
||||||
|
|
||||||
|
|
||||||
ConnectWidget( list_item );
|
ConnectWidget( list_item );
|
||||||
|
|
||||||
gtk_widget_show( list_item );
|
gtk_widget_show( list_item );
|
||||||
|
@@ -51,6 +51,8 @@ extern bool g_blockEventsOnDrag;
|
|||||||
extern bool g_blockEventsOnScroll;
|
extern bool g_blockEventsOnScroll;
|
||||||
extern wxCursor g_globalCursor;
|
extern wxCursor g_globalCursor;
|
||||||
extern wxWindowGTK *g_delayedFocus;
|
extern wxWindowGTK *g_delayedFocus;
|
||||||
|
extern wxWindowGTK *g_focusWindow;
|
||||||
|
extern wxWindowGTK *g_focusWindowLast;
|
||||||
|
|
||||||
static bool g_hasDoubleClicked = FALSE;
|
static bool g_hasDoubleClicked = FALSE;
|
||||||
|
|
||||||
@@ -87,6 +89,68 @@ extern "C" gint wxlistbox_idle_callback( gpointer gdata )
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// "focus_in_event"
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static gint gtk_listitem_focus_in_callback( GtkWidget *widget,
|
||||||
|
GdkEvent *WXUNUSED(event),
|
||||||
|
wxWindow *win )
|
||||||
|
{
|
||||||
|
if (g_isIdle)
|
||||||
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
|
g_focusWindowLast =
|
||||||
|
g_focusWindow = win;
|
||||||
|
|
||||||
|
// does the window itself think that it has the focus?
|
||||||
|
if ( !win->m_hasFocus )
|
||||||
|
{
|
||||||
|
// not yet, notify it
|
||||||
|
win->m_hasFocus = TRUE;
|
||||||
|
|
||||||
|
wxChildFocusEvent eventChildFocus(win);
|
||||||
|
(void)win->GetEventHandler()->ProcessEvent(eventChildFocus);
|
||||||
|
|
||||||
|
wxFocusEvent eventFocus(wxEVT_SET_FOCUS, win->GetId());
|
||||||
|
eventFocus.SetEventObject(win);
|
||||||
|
|
||||||
|
(void)win->GetEventHandler()->ProcessEvent(eventFocus);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// "focus_out_event"
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static gint gtk_listitem_focus_out_callback( GtkWidget *widget, GdkEventFocus *gdk_event, wxWindowGTK *win )
|
||||||
|
{
|
||||||
|
if (g_isIdle)
|
||||||
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
|
g_focusWindow = (wxWindowGTK *)NULL;
|
||||||
|
|
||||||
|
// don't send the window a kill focus event if it thinks that it doesn't
|
||||||
|
// have focus already
|
||||||
|
if ( win->m_hasFocus )
|
||||||
|
{
|
||||||
|
win->m_hasFocus = FALSE;
|
||||||
|
|
||||||
|
wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
|
||||||
|
event.SetEventObject( win );
|
||||||
|
|
||||||
|
// even if we did process the event in wx code, still let GTK itself
|
||||||
|
// process it too as otherwise bad things happen, especially in GTK2
|
||||||
|
// where the text control simply aborts the program if it doesn't get
|
||||||
|
// the matching focus out event
|
||||||
|
(void)win->GetEventHandler()->ProcessEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// "button_release_event"
|
// "button_release_event"
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -607,6 +671,14 @@ void wxListBox::GtkAddItem( const wxString &item, int pos )
|
|||||||
(GtkSignalFunc)gtk_listbox_key_press_callback,
|
(GtkSignalFunc)gtk_listbox_key_press_callback,
|
||||||
(gpointer)this );
|
(gpointer)this );
|
||||||
|
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(list_item), "focus_in_event",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_listitem_focus_in_callback), (gpointer)this );
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(list_item), "focus_out_event",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_listitem_focus_out_callback), (gpointer)this );
|
||||||
|
|
||||||
|
|
||||||
ConnectWidget( list_item );
|
ConnectWidget( list_item );
|
||||||
|
|
||||||
gtk_widget_show( list_item );
|
gtk_widget_show( list_item );
|
||||||
|
Reference in New Issue
Block a user