// the focus and the default processing should take place
bool DoSetFocus();
+ // can our child get the focus?
+ bool AcceptsFocus() const;
+
// called from OnChildFocus() handler, i.e. when one of our (grand)
// children gets the focus
void SetLastFocus(wxWindow *win);
virtual wxWindow *GetDefaultItem() const; \
virtual wxWindow *SetDefaultItem(wxWindow *child); \
virtual void SetTmpDefaultItem(wxWindow *win); \
+ virtual bool AcceptsFocus() const; \
\
protected: \
wxControlContainer m_container
void classname::OnFocus(wxFocusEvent& event) \
{ \
m_container.HandleOnFocus(event); \
+} \
+bool classname::AcceptsFocus() const \
+{ \
+ return m_container.AcceptsFocus(); \
}
m_winDefault = NULL;
}
+bool wxControlContainer::AcceptsFocus() const
+{
+ // We can accept focus only when at last one child will accept focus
+ if ( m_winParent->IsShown() && m_winParent->IsEnabled() )
+ {
+ wxWindowList::Node *node = m_winParent->GetChildren().GetFirst();
+ while ( node )
+ {
+ wxWindow *child = node->GetData();
+
+ if ( child->AcceptsFocus() )
+ {
+ return TRUE;
+ }
+
+ node = node->GetNext();
+ }
+ }
+
+ return FALSE;
+}
+
void wxControlContainer::SetLastFocus(wxWindow *win)
{
// the panel itself should never get the focus at all but if it does happen
return FALSE;
}
+