Add SetFocusIgnoringChildren() to wxControlContainer. This
makes corresponding hacks in wxListCtrl and wxTreeCtrl obsolete. With docs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30927 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -128,6 +128,7 @@ propagate the notification to child windows and controls.
|
|||||||
|
|
||||||
\helpref{wxSysColourChangedEvent}{wxsyscolourchangedevent}
|
\helpref{wxSysColourChangedEvent}{wxsyscolourchangedevent}
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxPanel::SetDefaultItem}\label{wxpanelsetdefaultitem}
|
\membersection{wxPanel::SetDefaultItem}\label{wxpanelsetdefaultitem}
|
||||||
|
|
||||||
\func{void}{SetDefaultItem}{\param{wxButton }{*btn}}
|
\func{void}{SetDefaultItem}{\param{wxButton }{*btn}}
|
||||||
@@ -138,3 +139,33 @@ Changes the default button for the panel.
|
|||||||
|
|
||||||
\helpref{GetDefaultItem}{wxpanelgetdefaultitem}
|
\helpref{GetDefaultItem}{wxpanelgetdefaultitem}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxPanel::SetFocus}\label{wxpanelsetfocus}
|
||||||
|
|
||||||
|
\func{virtual void}{SetFocus}{\void}
|
||||||
|
|
||||||
|
Overrides \helpref{wxWindow::SetFocus}{wxwindowsetfocus}. This method
|
||||||
|
uses the (undocumented) mix-in class wxControlContainer which manages
|
||||||
|
the focus and TAB logic for controls which usually have child controls.
|
||||||
|
In practice, if you call this method and the control has at least
|
||||||
|
one child window, the focus will be given to the child window.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxFocusEvent}{wxfocusevent}
|
||||||
|
\helpref{wxWindow::SetFocus}{wxwindowsetfocus}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxPanel::SetFocusIgnoringChildren}\label{wxpanelsetfocusignoringchildren}
|
||||||
|
|
||||||
|
\func{virtual void}{SetFocusIgnoringChildren}{\void}
|
||||||
|
|
||||||
|
In contrast to \helpref{wxPanel::SetFocus}{wxpanelsetfocus} (see above)
|
||||||
|
this will set the focus to the panel even of there are child windows
|
||||||
|
in the panel. This is only rarely needed.
|
||||||
|
|
||||||
|
\wxheading{See also}
|
||||||
|
|
||||||
|
\helpref{wxFocusEvent}{wxfocusevent}
|
||||||
|
\helpref{wxPanel::SetFocus}{wxpanelsetfocus}
|
||||||
|
|
||||||
|
@@ -2762,6 +2762,8 @@ This sets the window to receive keyboard input.
|
|||||||
\wxheading{See also}
|
\wxheading{See also}
|
||||||
|
|
||||||
\helpref{wxFocusEvent}{wxfocusevent}
|
\helpref{wxFocusEvent}{wxfocusevent}
|
||||||
|
\helpref{wxPanel::SetFocus}{wxpanelsetfocus}
|
||||||
|
\helpref{wxPanel::SetFocusIgnoringChildren}{wxpanelsetfocusignoringchildren}
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxWindow::SetFocusFromKbd}\label{wxwindowsetfocusfromkbd}
|
\membersection{wxWindow::SetFocusFromKbd}\label{wxwindowsetfocusfromkbd}
|
||||||
|
@@ -113,6 +113,7 @@ public: \
|
|||||||
void OnFocus(wxFocusEvent& event); \
|
void OnFocus(wxFocusEvent& event); \
|
||||||
virtual void OnChildFocus(wxChildFocusEvent& event); \
|
virtual void OnChildFocus(wxChildFocusEvent& event); \
|
||||||
virtual void SetFocus(); \
|
virtual void SetFocus(); \
|
||||||
|
virtual void SetFocusIgnoringChildren(); \
|
||||||
virtual void RemoveChild(wxWindowBase *child); \
|
virtual void RemoveChild(wxWindowBase *child); \
|
||||||
virtual wxWindow *GetDefaultItem() const; \
|
virtual wxWindow *GetDefaultItem() const; \
|
||||||
virtual wxWindow *SetDefaultItem(wxWindow *child); \
|
virtual wxWindow *SetDefaultItem(wxWindow *child); \
|
||||||
@@ -163,6 +164,11 @@ void classname::SetFocus() \
|
|||||||
wxWindow::SetFocus(); \
|
wxWindow::SetFocus(); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
void classname::SetFocusIgnoringChildren() \
|
||||||
|
{ \
|
||||||
|
wxWindow::SetFocus(); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
void classname::OnChildFocus(wxChildFocusEvent& event) \
|
void classname::OnChildFocus(wxChildFocusEvent& event) \
|
||||||
{ \
|
{ \
|
||||||
m_container.SetLastFocus(event.GetWindow()); \
|
m_container.SetLastFocus(event.GetWindow()); \
|
||||||
|
@@ -606,8 +606,6 @@ public:
|
|||||||
void Freeze();
|
void Freeze();
|
||||||
void Thaw();
|
void Thaw();
|
||||||
|
|
||||||
void SetFocus();
|
|
||||||
|
|
||||||
void OnRenameTimer();
|
void OnRenameTimer();
|
||||||
bool OnRenameAccept(size_t itemEdit, const wxString& value);
|
bool OnRenameAccept(size_t itemEdit, const wxString& value);
|
||||||
void OnRenameCancelled(size_t itemEdit);
|
void OnRenameCancelled(size_t itemEdit);
|
||||||
@@ -2047,7 +2045,7 @@ void wxListTextCtrl::Finish()
|
|||||||
|
|
||||||
m_finished = true;
|
m_finished = true;
|
||||||
|
|
||||||
m_owner->SetFocus();
|
m_owner->SetFocusIgnoringChildren();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3299,26 +3297,6 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
// focus handling
|
// focus handling
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxListMainWindow::SetFocus()
|
|
||||||
{
|
|
||||||
// VS: wxListMainWindow derives from wxPanel (via wxScrolledWindow) and wxPanel
|
|
||||||
// overrides SetFocus in such way that it does never change focus from
|
|
||||||
// panel's child to the panel itself. Unfortunately, we must be able to change
|
|
||||||
// focus to the panel from wxListTextCtrl because the text control should
|
|
||||||
// disappear when the user clicks outside it.
|
|
||||||
|
|
||||||
wxWindow *oldFocus = DoFindFocus();
|
|
||||||
|
|
||||||
if ( oldFocus && oldFocus->GetParent() == this )
|
|
||||||
{
|
|
||||||
wxWindow::SetFocus();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxScrolledWindow::SetFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
|
void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
if ( GetParent() )
|
if ( GetParent() )
|
||||||
|
@@ -415,7 +415,7 @@ void wxTreeTextCtrl::Finish()
|
|||||||
|
|
||||||
m_finished = true;
|
m_finished = true;
|
||||||
|
|
||||||
m_owner->SetFocus(); // This doesn't work. TODO.
|
m_owner->SetFocusIgnoringChildren();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user