
Even though the main window has lost focus, the sub pane still has the focus state drawn, despite me using wxAUI_MGR_ALLOW_ACTIVE_PANE. I tried fixing it but I just confused myself the more I read the code

Index: manager.cpp
===================================================================
--- manager.cpp (revision 601)
+++ manager.cpp (working copy)
@@ -552,6 +552,22 @@
}
}
+static wxPaneInfo* UnsetActivePane(wxPaneInfoArray& panes)
+{
+ int i, pane_count;
+ wxPaneInfo* info = NULL;
+ for (i = 0, pane_count = panes.GetCount(); i < pane_count; ++i)
+ {
+ wxPaneInfo& pane = panes.Item(i);
+ if (pane.state & wxPaneInfo::optionActive)
+ {
+ pane.state &= ~wxPaneInfo::optionActive;
+ info = &pane;
+ }
+ }
+
+ return info;
+}
// this function is used to sort panes by dock position
static int PaneSortFunc(wxPaneInfo** p1, wxPaneInfo** p2)
@@ -583,6 +599,7 @@
m_action = actionNone;
m_last_mouse_move = wxPoint();
m_hover_button = NULL;
+ m_last_selected = NULL;
m_art = new wxDefaultDockArt;
m_hint_wnd = NULL;
m_flags = flags;
@@ -714,6 +731,8 @@
CenterPane().PaneBorder(false));
}
#endif
+
+ m_frame->Connect(wxEVT_ACTIVATE, (wxObjectEventFunction)(wxActivateEventFunction)&wxFrameManager::OnActivated, NULL, this);
}
@@ -2590,7 +2609,6 @@
return false;
}
-
void wxFrameManager::OnHintFadeTimer(wxTimerEvent& /*event*/)
{
#ifdef __WXMSW__
@@ -3664,6 +3682,29 @@
}
}
+void wxFrameManager::OnActivated(wxActivateEvent& event)
+{
+ if (GetFlags() & wxAUI_MGR_ALLOW_ACTIVE_PANE)
+ {
+ if (event.GetActive())
+ {
+ if (m_last_selected)
+ {
+ SetActivePane(m_panes, m_last_selected);
+ m_last_selected = NULL;
+ }
+ }
+ else
+ {
+ wxPaneInfo* info = UnsetActivePane(m_panes);
+ if (info)
+ m_last_selected = info->window;
+ }
+ m_frame->Update();
+ m_frame->Refresh();
+ }
+}
+
void wxFrameManager::OnChildFocus(wxChildFocusEvent& event)
{
// when a child pane has it's focus set, we should change the
Index: manager.h
===================================================================
--- manager.h (revision 601)
+++ manager.h (working copy)
@@ -444,7 +444,8 @@
private:
// events
- void OnPaint(wxPaintEvent& event);
+ void OnActivated(wxActivateEvent& event);
+ void OnPaint(wxPaintEvent& event);
void OnEraseBackground(wxEraseEvent& event);
void OnSize(wxSizeEvent& event);
void OnSetCursor(wxSetCursorEvent& event);
@@ -488,6 +489,7 @@
wxRect m_last_hint; // last hint rectangle
wxPoint m_last_mouse_move; // last mouse move position (see OnMotion)
+ wxWindow* m_last_selected; // last focussed window before deactivation
wxWindow* m_hint_wnd; // transparent hint window (for now, only msw)
wxTimer m_hint_fadetimer; // transparent fade timer (for now, only msw)
int m_hint_fadeamt; // transparent fade amount (for now, only msw)
Return to wxAUI Questions, Thoughts & Feedback