\helpref{wxCloseEvent}{wxcloseevent}
+\membersection{wxWindow::AcceptsFocus}\label{wxwindowacceptsfocus}
+
+\constfunc{bool}{AcceptsFocus}{\void}
+
+This method may be overridden in the derived classes to return \false to
+indicate that this control doesn't accept input at all (i.e. behaves like e.g.
+\helpref{wxStaticText}{wxstatictext}) and so doesn't need focus.
+
+\wxheading{See also}
+
+\helpref{AcceptsFocusFromKeyboard}{wxwindowacceptsfocusfromkeyboard}
+
+
+\membersection{wxWindow::AcceptsFocusFromKeyboard}\label{wxwindowacceptsfocusfromkeyboard}
+
+\constfunc{bool}{AcceptsFocusFromKeyboard}{\void}
+
+This method may be overridden in the derived classes to return \false to
+indicate that while this control can, in principle, have focus if the user
+clicks it with the mouse, it shouldn't be included in the TAB traversal chain
+when using the keyboard.
+
+
\membersection{wxWindow::AddChild}\label{wxwindowaddchild}
\func{virtual void}{AddChild}{\param{wxWindow* }{child}}
static wxWindow *DoFindFocus() /* = 0: implement in derived classes */;
- // can this window have focus?
- virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }
+ // can this window have focus in principle?
+ //
+ // the difference between AcceptsFocus[FromKeyboard]() and CanAcceptFocus
+ // [FromKeyboard]() is that the former functions are meant to be
+ // overridden in the derived classes to simply return false if the
+ // control can't have focus, while the latter are meant to be used by
+ // this class clients and take into account the current window state
+ virtual bool AcceptsFocus() const { return true; }
+
+ // can this window have focus right now?
+ bool CanAcceptFocus() const { return AcceptsFocus() && IsShown() && IsEnabled(); }
// can this window be given focus by keyboard navigation? if not, the
// only way to give it focus (provided it accepts it at all) is to
// click it
virtual bool AcceptsFocusFromKeyboard() const { return AcceptsFocus(); }
+ // can this window be assigned focus from keyboard right now?
+ bool CanAcceptFocusFromKeyboard() const
+ { return AcceptsFocusFromKeyboard() && CanAcceptFocus(); }
+
// navigates in the specified direction by sending a wxNavigationKeyEvent
virtual bool Navigate(int flags = wxNavigationKeyEvent::IsForward);
{
SetDfbFocus();
}
- else if ( AcceptsFocus() )
+ else if ( CanAcceptFocus() )
{
// FIXME: we should probably always call SetDfbFocus instead
// and call SetFocus() from wxActivateEvent/DWET_GOTFOCUS
g_lastButtonNumber = gdk_event->button;
- if (win->m_wxwindow && (g_focusWindow != win) && win->AcceptsFocus())
+ if (win->m_wxwindow && (g_focusWindow != win) && win->CanAcceptFocus())
{
gtk_widget_grab_focus( win->m_wxwindow );
}
g_lastButtonNumber = gdk_event->button;
- if (win->m_wxwindow && (g_focusWindow != win) && win->AcceptsFocus())
+ if (win->m_wxwindow && (g_focusWindow != win) && win->CanAcceptFocus())
{
gtk_widget_grab_focus( win->m_wxwindow );
/*
if ( wxevent.GetEventType() == wxEVT_LEFT_DOWN )
{
// ... that is set focus to this window
- if (currentMouseWindow->AcceptsFocus() && wxWindow::FindFocus()!=currentMouseWindow)
+ if (currentMouseWindow->CanAcceptFocus() && wxWindow::FindFocus()!=currentMouseWindow)
currentMouseWindow->SetFocus();
}
GetEventHandler()->ProcessEvent(event);
}
- if ( ret && show && AcceptsFocus() )
+ if ( ret && show && CanAcceptFocus() )
SetFocus();
// FIXME_MGL -- don't do this for popup windows?
return ret;
{
case EVT_MOUSEDOWN:
// Change focus if the user clicks outside focused window:
- if ( win->AcceptsFocus() && wxWindow::FindFocus() != win )
+ if ( win->CanAcceptFocus() && wxWindow::FindFocus() != win )
win->SetFocus();
if ( e->message & EVT_DBLCLICK )
{
long msStyle = wxWindow::MSWGetStyle(style, exstyle);
- if ( AcceptsFocus() )
+ if ( AcceptsFocusFromKeyboard() )
{
msStyle |= WS_TABSTOP;
}
node = node->GetNext() )
{
wxWindow * const win = node->GetData();
- if ( win->AcceptsFocus() &&
+ if ( win->CanAcceptFocus() &&
!(::GetWindowLong(GetHwndOf(win), GWL_EXSTYLE) &
WS_EX_CONTROLPARENT) )
{
// problems, so don't do it for them (unnecessary anyhow)
if ( !win->IsOfStandardClass() )
{
- if ( message == WM_LBUTTONDOWN && win->AcceptsFocus() )
+ if ( message == WM_LBUTTONDOWN && win->CanAcceptFocus() )
win->SetFocus();
}
}
{
long dwStyle = wxWindow::OS2GetStyle( lStyle, pdwExstyle );
- if (AcceptsFocus())
+ if (AcceptsFocusFromKeyboard())
{
dwStyle |= WS_TABSTOP;
}
);
if (!pWin->IsOfStandardClass())
{
- if (uMsg == WM_BUTTON1DOWN && pWin->AcceptsFocus() )
+ if (uMsg == WM_BUTTON1DOWN && pWin->CanAcceptFocus() )
pWin->SetFocus();
}
bProcessed = pWin->HandleMouseEvent( uMsg
// clicking on the control gives it focus
if ( event.ButtonDown() )
{
- wxWindow *win = control->GetInputWindow();
+ wxWindow * const win = control->GetInputWindow();
- if ( (wxWindow::FindFocus() != control->GetInputWindow()) &&
- win->AcceptsFocus() )
+ if ( win->CanAcceptFocus() && wxWindow::FindFocus() != win )
{
win->SetFocus();
if (event->type == ButtonPress)
{
- if ((win != wxWindow::FindFocus()) && win->AcceptsFocus())
+ if ((win != wxWindow::FindFocus()) && win->CanAcceptFocus())
{
// This might actually be done in wxWindow::SetFocus()
// and not here. TODO.