With wxTE_PROCESS_TAB, tabs are now inserted in the text control
by default. The new Navigate function can be used to do navigation programmatically. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27807 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -111,6 +111,10 @@ All (GUI):
|
|||||||
is discouraged
|
is discouraged
|
||||||
- Added ..._CMD_... variants for wxGrid event table entry macros
|
- Added ..._CMD_... variants for wxGrid event table entry macros
|
||||||
taking window identifiers
|
taking window identifiers
|
||||||
|
- Added wxWindowBase::Navigate for programmatic navigation to the next
|
||||||
|
control.
|
||||||
|
- On most platforms, wxTextCtrl::OnChar now inserts a tab character if
|
||||||
|
wxTE_PROCESS_TAB is set, or navigates to the next control if not.
|
||||||
|
|
||||||
Unix:
|
Unix:
|
||||||
|
|
||||||
|
@@ -1448,6 +1448,26 @@ implements the following methods:\par
|
|||||||
\end{twocollist}}
|
\end{twocollist}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
\membersection{wxWindow::Navigate}\label{wxwindownavigate}
|
||||||
|
|
||||||
|
\func{bool}{Navigate}{\param{bool}{ direction = true}, \param{bool}{ windowChange = false}}
|
||||||
|
|
||||||
|
Does keyboard navigation from this window to another, by sending
|
||||||
|
a wxNavigationKeyEvent.
|
||||||
|
|
||||||
|
\wxheading{Parameters}
|
||||||
|
|
||||||
|
\docparam{direction}{{\tt true} to navigate forwards, {\tt false} to navigate backwards.}
|
||||||
|
|
||||||
|
\docparam{windowChange}{{\tt true} if the navigation is a window change.}
|
||||||
|
|
||||||
|
\wxheading{Remarks}
|
||||||
|
|
||||||
|
You may wish to call this from a text control custom keypress handler to do the default
|
||||||
|
navigation behaviour for the tab key, since the standard default behaviour for
|
||||||
|
a multiline text control with the wxTE\_PROCESS\_TAB style is to insert a tab
|
||||||
|
and not navigate to the next control.
|
||||||
|
|
||||||
%% VZ: wxWindow::OnXXX() functions should not be documented but I'm leaving
|
%% VZ: wxWindow::OnXXX() functions should not be documented but I'm leaving
|
||||||
%% the old docs here in case we want to move any still needed bits to
|
%% the old docs here in case we want to move any still needed bits to
|
||||||
%% the right location (i.e. probably the corresponding events docs)
|
%% the right location (i.e. probably the corresponding events docs)
|
||||||
|
@@ -489,6 +489,9 @@ public:
|
|||||||
// set this child as temporary default
|
// set this child as temporary default
|
||||||
virtual void SetTmpDefaultItem(wxWindow * WXUNUSED(win)) { }
|
virtual void SetTmpDefaultItem(wxWindow * WXUNUSED(win)) { }
|
||||||
|
|
||||||
|
// Navigates in the specified direction by sending a wxNavigationKeyEvent
|
||||||
|
virtual bool Navigate(bool direction = true, bool windowChange = false);
|
||||||
|
|
||||||
// parent/children relations
|
// parent/children relations
|
||||||
// -------------------------
|
// -------------------------
|
||||||
|
|
||||||
|
@@ -2400,6 +2400,24 @@ bool wxWindowBase::TryParent(wxEvent& event)
|
|||||||
return wxEvtHandler::TryParent(event);
|
return wxEvtHandler::TryParent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// navigation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Navigates in the specified direction.
|
||||||
|
bool wxWindowBase::Navigate(bool direction, bool windowChange)
|
||||||
|
{
|
||||||
|
wxNavigationKeyEvent eventNav;
|
||||||
|
eventNav.SetDirection(direction);
|
||||||
|
eventNav.SetWindowChange(windowChange);
|
||||||
|
eventNav.SetEventObject(this);
|
||||||
|
if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// global functions
|
// global functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -1985,21 +1985,10 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_TAB:
|
case WXK_TAB:
|
||||||
// always produce navigation event - even if we process TAB
|
if ( !(m_windowStyle & wxTE_PROCESS_TAB))
|
||||||
// ourselves the fact that we got here means that the user code
|
|
||||||
// decided to skip processing of this TAB - probably to let it
|
|
||||||
// do its default job.
|
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent eventNav;
|
if (Navigate(!event.ShiftDown(), event.ControlDown()))
|
||||||
eventNav.SetDirection(!event.ShiftDown());
|
|
||||||
eventNav.SetWindowChange(event.ControlDown());
|
|
||||||
eventNav.SetEventObject(this);
|
|
||||||
|
|
||||||
if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.Skip() ;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -1649,21 +1649,10 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_TAB:
|
case WXK_TAB:
|
||||||
// always produce navigation event - even if we process TAB
|
if ( !(m_windowStyle & wxTE_PROCESS_TAB))
|
||||||
// ourselves the fact that we got here means that the user code
|
|
||||||
// decided to skip processing of this TAB - probably to let it
|
|
||||||
// do its default job.
|
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent eventNav;
|
if (Navigate(!event.ShiftDown(), event.ControlDown()))
|
||||||
eventNav.SetDirection(!event.ShiftDown());
|
|
||||||
eventNav.SetWindowChange(event.ControlDown());
|
|
||||||
eventNav.SetEventObject(this);
|
|
||||||
|
|
||||||
if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.Skip() ;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -1689,11 +1689,6 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_TAB:
|
case WXK_TAB:
|
||||||
// always produce navigation event -- even if we process TAB
|
|
||||||
// ourselves the fact that we got here means that the user code
|
|
||||||
// decided to skip processing of this TAB -- probably to let it
|
|
||||||
// do its default job.
|
|
||||||
|
|
||||||
// ok, so this is getting absolutely ridiculous but I don't see
|
// ok, so this is getting absolutely ridiculous but I don't see
|
||||||
// any other way to fix this bug: when a multiline text control is
|
// any other way to fix this bug: when a multiline text control is
|
||||||
// inside a wxFrame, we need to generate the navigation event as
|
// inside a wxFrame, we need to generate the navigation event as
|
||||||
@@ -1708,15 +1703,19 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
// the right thing to do would, of course, be to understand what
|
// the right thing to do would, of course, be to understand what
|
||||||
// the hell is IsDialogMessage() doing but this is beyond my feeble
|
// the hell is IsDialogMessage() doing but this is beyond my feeble
|
||||||
// forces at the moment unfortunately
|
// forces at the moment unfortunately
|
||||||
if ( FindFocus() == this )
|
if ( !(m_windowStyle & wxTE_PROCESS_TAB))
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent eventNav;
|
if ( FindFocus() == this )
|
||||||
eventNav.SetDirection(!event.ShiftDown());
|
{
|
||||||
eventNav.SetWindowChange(event.ControlDown());
|
if (Navigate(!event.ShiftDown(), event.ControlDown()))
|
||||||
eventNav.SetEventObject(this);
|
return;
|
||||||
|
}
|
||||||
if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
|
}
|
||||||
return;
|
else
|
||||||
|
{
|
||||||
|
// Insert tab since calling the default Windows handler
|
||||||
|
// doesn't seem to do it
|
||||||
|
WriteText(wxT("\t"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user