]> git.saurik.com Git - wxWidgets.git/commitdiff
use native TAB traversal for GTK+ 2
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 26 Mar 2007 19:30:20 +0000 (19:30 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 26 Mar 2007 19:30:20 +0000 (19:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45073 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

27 files changed:
include/wx/containr.h
include/wx/gtk/window.h
src/gtk/animate.cpp
src/gtk/bmpbuttn.cpp
src/gtk/button.cpp
src/gtk/checkbox.cpp
src/gtk/choice.cpp
src/gtk/clrpicker.cpp
src/gtk/collpane.cpp
src/gtk/combobox.cpp
src/gtk/dataview.cpp
src/gtk/filepicker.cpp
src/gtk/fontpicker.cpp
src/gtk/hyperlink.cpp
src/gtk/listbox.cpp
src/gtk/notebook.cpp
src/gtk/popupwin.cpp
src/gtk/radiobox.cpp
src/gtk/radiobut.cpp
src/gtk/scrolbar.cpp
src/gtk/slider.cpp
src/gtk/spinctrl.cpp
src/gtk/textctrl.cpp
src/gtk/tglbtn.cpp
src/gtk/toplevel.cpp
src/gtk/win_gtk.c
src/gtk/window.cpp

index e6750713bcdb053b19e7c0b5ea303ae8573fddd0..af248caf738898aa46ee15b5d08d192665d1c590 100644 (file)
@@ -14,7 +14,7 @@
 #define _WX_CONTAINR_H_
 
 // use native tab traversal logic under GTK+ 2 (doesn't work yet)
-#if 0 // def __WXGTK20__
+#ifdef __WXGTK20__
     #define wxHAS_NATIVE_TAB_TRAVERSAL
 #endif
 
index 9c92179ca33596dec122c8685c81f1e18e44b465..e8d0e60fe3cae7a0edf52bf6b7f7be0336baa747 100644 (file)
@@ -68,7 +68,6 @@ public:
     virtual bool IsRetained() const;
 
     virtual void SetFocus();
-    virtual bool AcceptsFocus() const;
 
     virtual bool Reparent( wxWindowBase *newParent );
 
@@ -183,7 +182,7 @@ public:
 
 protected:
     // Override GTKWidgetNeedsMnemonic and return true if your
-    // needs to set its mnemonic widget, such as for a 
+    // needs to set its mnemonic widget, such as for a
     // GtkLabel for wxStaticText, then do the actual
     // setting of the widget inside GTKWidgetDoSetMnemonic
     virtual bool GTKWidgetNeedsMnemonic() const;
@@ -219,13 +218,13 @@ public:
     // the layouting functions have to be called later on
     // (i.e. in idle time, implemented in OnInternalIdle() ).
     void GtkUpdateSize() { m_sizeSet = false; }
-    
-    
+
+
     // Called when a window should delay showing itself
     // until idle time. This partly mimmicks defered
     // sizing under MSW.
     void GtkShowOnIdle() { m_showOnIdle = true; }
-    
+
     // This is called from the various OnInternalIdle methods
     bool GtkShowFromOnIdle();
 
@@ -299,7 +298,6 @@ public:
     bool                 m_hasVMT:1;
     bool                 m_sizeSet:1;
     bool                 m_resizing:1;
-    bool                 m_acceptsFocus:1;      // true if not static
     bool                 m_hasFocus:1;          // true if == FindFocus()
     bool                 m_isScrolling:1;       // dragging scrollbar thumb?
     bool                 m_clipPaintRegion:1;   // true after ScrollWindow()
@@ -310,7 +308,7 @@ public:
                                                 // background style until OnIdle
     bool                 m_mouseButtonDown:1;
     bool                 m_blockScrollEvent:1;
-    
+
     bool                 m_showOnIdle:1;        // postpone showing the window until idle
 
     // C++ has no virtual methods in the constrcutor of any class but we need
index e6e6b8b0f903c42bf5fdd15db05e71b6bc1f7ce8..2999905883cff346d685801b0336b0416e269408 100644 (file)
@@ -200,7 +200,6 @@ bool wxAnimationCtrl::Create( wxWindow *parent, wxWindowID id,
                               const wxString& name)
 {
     m_needParent = true;
-    m_acceptsFocus = true;
 
     if (!PreCreation( parent, pos, size ) ||
         !base_type::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
index cc9f6d14e7662692f41d9af22127836ae657b6a7..6ec496ea1a15b61e945176e6579199ff114bfc76 100644 (file)
@@ -125,7 +125,6 @@ bool wxBitmapButton::Create( wxWindow *parent,
                              const wxString &name )
 {
     m_needParent = true;
-    m_acceptsFocus = true;
 
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, validator, name ))
index 35e0b4f53712a2e9aec2134106ba835bbff4f4d7..3e4e83feebab585892ab87731b931c269dc71c22 100644 (file)
@@ -111,7 +111,6 @@ bool wxButton::Create(  wxWindow *parent, wxWindowID id, const wxString &label,
       long style, const wxValidator& validator, const wxString &name )
 {
     m_needParent = true;
-    m_acceptsFocus = true;
 
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, validator, name ))
index 7dcc25d78f9527f07063671d146efd7a9e6b299a..f3352a13977f767c1450af8bee067361ec3c3c80 100644 (file)
@@ -110,7 +110,6 @@ bool wxCheckBox::Create(wxWindow *parent,
                         const wxString &name )
 {
     m_needParent = true;
-    m_acceptsFocus = true;
     m_blockEvent = false;
 
     if (!PreCreation( parent, pos, size ) ||
index 02b6c41b2a617de22f10821042790c5e44819638..b159c5e9841b06e3ceee640c2812ca6792ed80bc 100644 (file)
@@ -98,9 +98,6 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
                        long style, const wxValidator& validator, const wxString &name )
 {
     m_needParent = true;
-#if (GTK_MINOR_VERSION > 0)
-    m_acceptsFocus = true;
-#endif
 
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, validator, name ))
index a8ed5ef927734835a2a8544a3b834ce197dd2c34..a710f9fa336f7f8df99f13cbbd4a856d3e81b4d9 100644 (file)
@@ -62,7 +62,6 @@ bool wxColourButton::Create( wxWindow *parent, wxWindowID id,
     if (!gtk_check_version(2,4,0))
     {
         m_needParent = true;
-        m_acceptsFocus = true;
 
         if (!PreCreation( parent, pos, size ) ||
             !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
index 93b0be56e1f00c3f72aed99199db10e4c5683365..3ba9f7e25fe4f700671b80b55b2521c96795a412 100644 (file)
@@ -199,7 +199,6 @@ bool wxCollapsiblePane::Create(wxWindow *parent,
                                                 pos, size, style, val, name);
 
     m_needParent = true;
-    m_acceptsFocus = true;
     m_bIgnoreNextChange = false;
 
     if ( !PreCreation( parent, pos, size ) ||
index d4c88afb037a5c1a93f446c28c0a800971f23347..1a4e40ce0f180a690c82d40264e2dd2b7fffbc50 100644 (file)
@@ -251,7 +251,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
 {
     m_ignoreNextUpdate = false;
     m_needParent = true;
-    m_acceptsFocus = true;
     m_prevSelection = 0;
 
     if (!PreCreation( parent, pos, size ) ||
index c075c1dfe42bde10bdd5234fc185f02e492e2034..a7c4bc7c7255a652d2e4cf2f7b4384722a30c060 100644 (file)
@@ -1882,7 +1882,6 @@ bool wxDataViewCtrl::Create(wxWindow *parent, wxWindowID id,
     Init();
 
     m_needParent = true;
-    m_acceptsFocus = true;
 
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, validator ))
index c79eb51426266ab58c1ede414a08360d0a82e0ab..32d0c628080ac0150ec14ea747b79708ecb3507f 100644 (file)
@@ -47,7 +47,6 @@ bool wxFileButton::Create( wxWindow *parent, wxWindowID id,
         //                 if you find a problem here, fix it also in wxDirButton !
 
         m_needParent = true;
-        m_acceptsFocus = true;
 
         if (!PreCreation( parent, pos, size ) ||
             !wxControl::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
@@ -197,7 +196,6 @@ bool wxDirButton::Create( wxWindow *parent, wxWindowID id,
         //                 if you find a problem here, fix it also in wxFileButton !
 
         m_needParent = true;
-        m_acceptsFocus = true;
 
         if (!PreCreation( parent, pos, size ) ||
             !wxControl::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
index bc24c2e8d8f337098d48dff73b683aa4e408009e..97102051c86dee3af7d11986d48e3b68abe2eaf4 100644 (file)
@@ -61,7 +61,6 @@ bool wxFontButton::Create( wxWindow *parent, wxWindowID id,
     if (!gtk_check_version(2,4,0))
     {
         m_needParent = true;
-        m_acceptsFocus = true;
 
         if (!PreCreation( parent, pos, size ) ||
             !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
index 697d7e358b8eeff48b5ffe04d8ea556460fb5ac9..046c601aeb8a811a43ad70aebb1a0af04667e33b 100644 (file)
@@ -77,7 +77,6 @@ bool wxHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
         CheckParams(label, url, style);
 
         m_needParent = true;
-        m_acceptsFocus = true;
 
         if (!PreCreation( parent, pos, size ) ||
             !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
index e4bbf51aaecb47aab8877746d2c229f43502d405..1502a4f4f791257af3d78d9629cb09bb460411a9 100644 (file)
@@ -335,7 +335,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
                         const wxString &name )
 {
     m_needParent = true;
-    m_acceptsFocus = true;
     m_blockEvent = false;
 
     if (!PreCreation( parent, pos, size ) ||
index 172bc4b1207448f7084b9c7f8a792571df20c50d..14ce6bfac3b3dbd7b76190d6d8cef95448138a90 100644 (file)
@@ -162,77 +162,6 @@ gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win )
 }
 }
 
-//-----------------------------------------------------------------------------
-// "key_press_event"
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static gboolean
-gtk_notebook_key_press_callback( GtkWidget   *widget,
-                                 GdkEventKey *gdk_event,
-                                 wxNotebook  *notebook )
-{
-    // don't need to install idle handler, its done from "event" signal
-
-    if (!notebook->m_hasVMT) return FALSE;
-    if (g_blockEventsOnDrag) return FALSE;
-
-    /* win is a control: tab can be propagated up */
-    if ((gdk_event->keyval == GDK_Left) || (gdk_event->keyval == GDK_Right))
-    {
-        int page;
-        int nMax = notebook->GetPageCount();
-        if ( nMax-- ) // decrement it to get the last valid index
-        {
-            int nSel = notebook->GetSelection();
-
-            // change selection wrapping if it becomes invalid
-            page = (gdk_event->keyval != GDK_Left) ? nSel == nMax ? 0
-                                       : nSel + 1
-                        : nSel == 0 ? nMax
-                                    : nSel - 1;
-        }
-        else // notebook is empty, no next page
-        {
-            return FALSE;
-        }
-
-        gtk_notebook_set_current_page( GTK_NOTEBOOK(widget), page );
-
-        return TRUE;
-    }
-
-    /* win is a control: tab can be propagated up */
-    if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab))
-    {
-        int sel = notebook->GetSelection();
-        if (sel == -1)
-            return TRUE;
-        wxGtkNotebookPage *nb_page = notebook->GetNotebookPage(sel);
-        wxCHECK_MSG( nb_page, FALSE, _T("invalid selection in wxNotebook") );
-
-        wxNavigationKeyEvent event;
-        event.SetEventObject( notebook );
-        /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
-        event.SetDirection( (gdk_event->keyval == GDK_Tab) );
-        /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
-        event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) ||
-                               (gdk_event->keyval == GDK_Left) || (gdk_event->keyval == GDK_Right) );
-        event.SetCurrentFocus( notebook );
-
-        wxNotebookPage *client = notebook->GetPage(sel);
-        if ( !client->GetEventHandler()->ProcessEvent( event ) )
-        {
-             client->SetFocus();
-        }
-
-        return TRUE;
-    }
-
-    return FALSE;
-}
-}
-
 //-----------------------------------------------------------------------------
 // InsertChild callback for wxNotebook
 //-----------------------------------------------------------------------------
@@ -296,7 +225,6 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
                         long style, const wxString& name )
 {
     m_needParent = true;
-    m_acceptsFocus = true;
     m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
 
     if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
@@ -329,9 +257,6 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
     if (m_windowStyle & wxBK_BOTTOM)
         gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM );
 
-    g_signal_connect (m_widget, "key_press_event",
-                      G_CALLBACK (gtk_notebook_key_press_callback), this);
-
     PostCreation(size);
 
     g_signal_connect (m_widget, "realize",
index 8d1a10b4f9cc78d04e7112466ee1238b0f8a3f2b..2de47c76c0d304eab492cb0e81125201bec860d2 100644 (file)
@@ -65,21 +65,6 @@ static gint gtk_popup_button_press (GtkWidget *widget, GdkEvent *gdk_event, wxPo
 }
 }
 
-//-----------------------------------------------------------------------------
-// "focus" from m_window
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static gint gtk_dialog_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
-{
-    if (g_isIdle)
-        wxapp_install_idle_handler();
-
-    /* This disables GTK's tab traversal */
-    return TRUE;
-}
-}
-
 //-----------------------------------------------------------------------------
 // "delete_event"
 //-----------------------------------------------------------------------------
@@ -209,10 +194,6 @@ bool wxPopupWindow::Create( wxWindow *parent, int style )
     g_signal_connect (m_widget, "realize",
                       G_CALLBACK (gtk_dialog_realized_callback), this);
 
-    // disable native tab traversal
-    g_signal_connect (m_widget, "focus",
-                      G_CALLBACK (gtk_dialog_focus_callback), this);
-
     m_time = gtk_get_current_event_time();
 
     g_signal_connect (m_widget, "button_press_event",
index e84d215469fbda5c7e65c52463dd0f1e2aa8cb42..911aa6ccaba0fd0c5fb06b055db6164d13d8b14a 100644 (file)
@@ -219,7 +219,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl)
 void wxRadioBox::Init()
 {
     m_needParent = true;
-    m_acceptsFocus = true;
 
     m_hasFocus =
     m_lostFocus = false;
index 400b101454b5fe77b956e10cca84cdf66f92614d..f52faff09efe93b8a11e4caf50ed01eb28a5a602 100644 (file)
@@ -62,7 +62,6 @@ bool wxRadioButton::Create( wxWindow *parent,
                             const wxValidator& validator,
                             const wxString& name )
 {
-    m_acceptsFocus = TRUE;
     m_needParent = TRUE;
 
     m_blockEvent = FALSE;
index 00ea88097329bf6c5205f06d55c51726004bc47c..492678bd8855a09abd736b21571d723812a048d0 100644 (file)
@@ -134,7 +134,6 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
            long style, const wxValidator& validator, const wxString& name )
 {
     m_needParent = true;
-    m_acceptsFocus = true;
 
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, validator, name ))
index 269d2c4921f752aed034ed88eda44c512528598f..a8c1451100a38e918228cb3af04de60ec7d1c199 100644 (file)
@@ -288,7 +288,6 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
         const wxPoint& pos, const wxSize& size,
         long style, const wxValidator& validator, const wxString& name )
 {
-    m_acceptsFocus = true;
     m_needParent = true;
 
     if (!PreCreation( parent, pos, size ) ||
index 2cea9634f589c038764cb583adcd1d9fd106dd1d..1c0a9fcfa0bfdf465a52e49e1e4d7e4bebd424dc 100644 (file)
@@ -102,7 +102,6 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
                         const wxString& name)
 {
     m_needParent = true;
-    m_acceptsFocus = true;
 
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
index caa6405299af908b6d8ad1458e5b73de88a3c266..4fc49796fb41df88ab1dc1899c154ba9b7f67770 100644 (file)
@@ -685,7 +685,6 @@ bool wxTextCtrl::Create( wxWindow *parent,
                          const wxString &name )
 {
     m_needParent = true;
-    m_acceptsFocus = true;
 
     if (!PreCreation( parent, pos, size ) ||
         !CreateBase( parent, id, pos, size, style, validator, name ))
index c90a09ec6d88f1a3681aeed148b5826143af68a7..134fa7a9d5c8ef60c80260b1c156b63e671c7af5 100644 (file)
@@ -59,7 +59,6 @@ bool wxToggleBitmapButton::Create(wxWindow *parent, wxWindowID id,
                             const wxString &name)
 {
     m_needParent = true;
-    m_acceptsFocus = true;
 
     m_blockEvent = false;
 
@@ -202,7 +201,6 @@ bool wxToggleButton::Create(wxWindow *parent, wxWindowID id,
                             const wxString &name)
 {
     m_needParent = true;
-    m_acceptsFocus = true;
 
     m_blockEvent = false;
 
index e3e320f77ee2eaa6d8ead0cb28ef92f9adc08ac9..7227e4887fff368f4829b65e0132d5043e946b46 100644 (file)
@@ -197,23 +197,6 @@ static gboolean gtk_frame_focus_out_callback( GtkWidget *widget,
 }
 }
 
-//-----------------------------------------------------------------------------
-// "focus" from m_window
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static gboolean gtk_frame_focus_callback( GtkWidget *WXUNUSED(widget),
-                                          GtkDirectionType WXUNUSED(d),
-                                          wxWindow *WXUNUSED(win) )
-{
-    if (g_isIdle)
-        wxapp_install_idle_handler();
-
-    // This disables GTK's tab traversal
-    return TRUE;
-}
-}
-
 //-----------------------------------------------------------------------------
 // "size_allocate"
 //-----------------------------------------------------------------------------
@@ -628,10 +611,6 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
     g_signal_connect (m_widget, "configure_event",
                       G_CALLBACK (gtk_frame_configure_callback), this);
 
-    // disable native tab traversal
-    g_signal_connect (m_widget, "focus",
-                      G_CALLBACK (gtk_frame_focus_callback), this);
-
     // activation
     g_signal_connect_after (m_widget, "focus_in_event",
                       G_CALLBACK (gtk_frame_focus_in_callback), this);
index 2b6944fb3e22a5fcf148deb77a782084bd865e42..caa1b5f497158c9d5203f5d421987a79cb8b82c5 100644 (file)
@@ -198,6 +198,7 @@ gtk_pizza_child_type (GtkContainer     *container)
 static void
 gtk_pizza_init (GtkPizza *pizza)
 {
+    GTK_WIDGET_SET_FLAGS (pizza, GTK_CAN_FOCUS);
     GTK_WIDGET_UNSET_FLAGS (pizza, GTK_NO_WINDOW);
 
     pizza->children = NULL;
index 3d372237edaa63913dcb0c785395901f2e443c88..291b13c614a85d31b66bbcae887501068072b80d 100644 (file)
@@ -1114,30 +1114,6 @@ gtk_window_key_press_callback( GtkWidget *widget,
         }
     }
 
-    // win is a control: tab can be propagated up
-    if ( !ret &&
-         ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
-// VZ: testing for wxTE_PROCESS_TAB shouldn't be done here - the control may
-//     have this style, yet choose not to process this particular TAB in which
-//     case TAB must still work as a navigational character
-// JS: enabling again to make consistent with other platforms
-//     (with wxTE_PROCESS_TAB you have to call Navigate to get default
-//     navigation behaviour)
-#if wxUSE_TEXTCTRL
-         (! (win->HasFlag(wxTE_PROCESS_TAB) && win->IsKindOf(CLASSINFO(wxTextCtrl)) )) &&
-#endif
-         win->GetParent() && (win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
-    {
-        wxNavigationKeyEvent new_event;
-        new_event.SetEventObject( win->GetParent() );
-        // GDK reports GDK_ISO_Left_Tab for SHIFT-TAB
-        new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
-        // CTRL-TAB changes the (parent) window, i.e. switch notebook page
-        new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
-        new_event.SetCurrentFocus( win );
-        ret = win->GetParent()->GetEventHandler()->ProcessEvent( new_event );
-    }
-
     return ret;
 }
 }
@@ -1928,6 +1904,25 @@ gtk_window_focus_out_callback( GtkWidget *widget,
     return FALSE;
 }
 
+static gboolean
+wx_window_focus_callback(GtkWidget *widget,
+                         GtkDirectionType direction,
+                         wxWindowGTK *win)
+{
+    // the default handler for focus signal in GtkPizza (or, rather, in
+    // GtkScrolledWindow from which GtkPizza inherits this behaviour) sets
+    // focus to the window itself even if it doesn't accept focus, i.e. has no
+    // GTK_CAN_FOCUS in its style -- work around this by forcibly preventing
+    // the signal from reaching gtk_scrolled_window_focus() if we don't have
+    // any children which might accept focus (we know we don't accept the focus
+    // ourselves as this signal is only connected in this case)
+    if ( win->GetChildren().empty() )
+        g_signal_stop_emission_by_name(widget, "focus");
+
+    // we didn't change the focus
+    return FALSE;
+}
+
 //-----------------------------------------------------------------------------
 // "enter_notify_event"
 //-----------------------------------------------------------------------------
@@ -2283,7 +2278,6 @@ void wxWindowGTK::Init()
 
     m_insertCallback = (wxInsertChildFunction) NULL;
 
-    m_acceptsFocus = false;
     m_hasFocus = false;
 
     m_clipPaintRegion = false;
@@ -2330,7 +2324,6 @@ bool wxWindowGTK::Create( wxWindow *parent,
     m_insertCallback = wxInsertChildInWindow;
 
     m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
-    GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
 
     GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
 
@@ -2365,9 +2358,6 @@ bool wxWindowGTK::Create( wxWindow *parent,
 
     gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
 
-    GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
-    m_acceptsFocus = true;
-
     // connect various scroll-related events
     for ( int dir = 0; dir < ScrollDir_Max; dir++ )
     {
@@ -2516,6 +2506,16 @@ void wxWindowGTK::PostCreation()
         }
     }
 
+    if ( !AcceptsFocusFromKeyboard() )
+    {
+        GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
+        if ( m_wxwindow )
+            GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
+
+        g_signal_connect(m_widget, "focus",
+                            G_CALLBACK(wx_window_focus_callback), this);
+    }
+
     // connect to the various key and mouse handlers
 
     GtkWidget *connect_widget = GetConnectWidget();
@@ -3218,11 +3218,6 @@ void wxWindowGTK::SetFocus()
     }
 }
 
-bool wxWindowGTK::AcceptsFocus() const
-{
-    return m_acceptsFocus && wxWindowBase::AcceptsFocus();
-}
-
 bool wxWindowGTK::Reparent( wxWindowBase *newParentBase )
 {
     wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") );