From 7cec1c9e153bd1dca8c3f27353466762ae82c7f7 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 15 Sep 2007 22:06:22 +0000 Subject: [PATCH 1/1] Implement wxWindow::SetFocusIgnoringChildren for GTK+ git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48712 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/containr.h | 2 +- include/wx/gtk/window.h | 1 + src/gtk/window.cpp | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/wx/containr.h b/include/wx/containr.h index 41a8bbe336..0d38361739 100644 --- a/include/wx/containr.h +++ b/include/wx/containr.h @@ -177,7 +177,7 @@ protected: \ void classname::SetFocusIgnoringChildren() \ { \ - SetFocus(); \ + basename::SetFocusIgnoringChildren(); \ } #else // !wxHAS_NATIVE_TAB_TRAVERSAL diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 038127f487..2a623ee0c1 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -60,6 +60,7 @@ public: virtual bool IsRetained() const; virtual void SetFocus(); + virtual void SetFocusIgnoringChildren(); virtual void SetCanFocus(bool canFocus); virtual bool Reparent( wxWindowBase *newParent ); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 363f13d445..bb6bd9a565 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -3172,6 +3172,24 @@ bool wxWindowGTK::GTKSetDelayedFocusIfNeeded() return false; } +void wxWindowGTK::SetFocusIgnoringChildren() +{ + wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); + if ( m_hasFocus ) + { + // don't do anything if we already have focus + return; + } + + if (m_wxwindow) + { + if (!GTK_WIDGET_CAN_FOCUS(m_wxwindow)) + GTK_WIDGET_SET_FLAGS(m_wxwindow, GTK_CAN_FOCUS); + } + + wxWindowGTK::SetFocus(); +} + void wxWindowGTK::SetFocus() { wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); -- 2.45.2