From 4ae5ada038560a7fe793e9152f86d1d35b40f439 Mon Sep 17 00:00:00 2001
From: Paul Cornett <paulcor@bullseye.com>
Date: Wed, 31 Jul 2013 16:03:51 +0000
Subject: [PATCH] defer calling SetCanFocus() on wxGTK until after creation

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74618 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 include/wx/statbox.h      | 2 +-
 src/common/statboxcmn.cpp | 7 +++++++
 src/gtk/statbox.cpp       | 2 ++
 src/gtk/window.cpp        | 5 +++--
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/include/wx/statbox.h b/include/wx/statbox.h
index 02197a2479..d01f257969 100644
--- a/include/wx/statbox.h
+++ b/include/wx/statbox.h
@@ -27,7 +27,7 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxStaticBoxNameStr[];
 class WXDLLIMPEXP_CORE wxStaticBoxBase : public wxNavigationEnabled<wxControl>
 {
 public:
-    wxStaticBoxBase() { m_container.DisableSelfFocus(); }
+    wxStaticBoxBase();
 
     // overridden base class virtuals
     virtual bool HasTransparentBackground() { return true; }
diff --git a/src/common/statboxcmn.cpp b/src/common/statboxcmn.cpp
index 487036e122..5f0f05cbeb 100644
--- a/src/common/statboxcmn.cpp
+++ b/src/common/statboxcmn.cpp
@@ -29,6 +29,13 @@
 
 extern WXDLLEXPORT_DATA(const char) wxStaticBoxNameStr[] = "groupBox";
 
+wxStaticBoxBase::wxStaticBoxBase()
+{
+#ifndef __WXGTK__
+    m_container.DisableSelfFocus();
+#endif
+}
+
 // ----------------------------------------------------------------------------
 // XTI
 // ----------------------------------------------------------------------------
diff --git a/src/gtk/statbox.cpp b/src/gtk/statbox.cpp
index bd64a6076d..6d0a9b0db1 100644
--- a/src/gtk/statbox.cpp
+++ b/src/gtk/statbox.cpp
@@ -108,6 +108,8 @@ bool wxStaticBox::Create( wxWindow *parent,
     }
 #endif
 
+    m_container.DisableSelfFocus();
+
     return true;
 }
 
diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp
index 3e555410ff..0285a47912 100644
--- a/src/gtk/window.cpp
+++ b/src/gtk/window.cpp
@@ -3375,8 +3375,9 @@ void wxWindowGTK::SetFocus()
 
 void wxWindowGTK::SetCanFocus(bool canFocus)
 {
-    if ( m_widget )
-        gtk_widget_set_can_focus(m_widget, canFocus);
+    wxCHECK_RET(m_widget, "invalid window");
+
+    gtk_widget_set_can_focus(m_widget, canFocus);
 
     if ( m_wxwindow && (m_widget != m_wxwindow) )
     {
-- 
2.47.2