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:
Julian Smart
2004-06-15 14:03:06 +00:00
parent 1ab608ee00
commit 5f6cfda79f
7 changed files with 61 additions and 39 deletions

View File

@@ -111,6 +111,10 @@ All (GUI):
is discouraged
- Added ..._CMD_... variants for wxGrid event table entry macros
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:

View File

@@ -1448,6 +1448,26 @@ implements the following methods:\par
\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
%% 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)

View File

@@ -489,6 +489,9 @@ public:
// set this child as temporary default
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
// -------------------------

View File

@@ -2400,6 +2400,24 @@ bool wxWindowBase::TryParent(wxEvent& 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
// ----------------------------------------------------------------------------

View File

@@ -1985,20 +1985,9 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
break;
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.
if ( !(m_windowStyle & wxTE_PROCESS_TAB))
{
wxNavigationKeyEvent eventNav;
eventNav.SetDirection(!event.ShiftDown());
eventNav.SetWindowChange(event.ControlDown());
eventNav.SetEventObject(this);
if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
return;
event.Skip() ;
if (Navigate(!event.ShiftDown(), event.ControlDown()))
return;
}
break;

View File

@@ -1649,20 +1649,9 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
break;
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.
if ( !(m_windowStyle & wxTE_PROCESS_TAB))
{
wxNavigationKeyEvent eventNav;
eventNav.SetDirection(!event.ShiftDown());
eventNav.SetWindowChange(event.ControlDown());
eventNav.SetEventObject(this);
if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
return;
event.Skip() ;
if (Navigate(!event.ShiftDown(), event.ControlDown()))
return;
}
break;

View File

@@ -1689,11 +1689,6 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
break;
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
// any other way to fix this bug: when a multiline text control is
// inside a wxFrame, we need to generate the navigation event as
@@ -1708,16 +1703,20 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
// the right thing to do would, of course, be to understand what
// the hell is IsDialogMessage() doing but this is beyond my feeble
// forces at the moment unfortunately
if ( !(m_windowStyle & wxTE_PROCESS_TAB))
{
if ( FindFocus() == this )
{
wxNavigationKeyEvent eventNav;
eventNav.SetDirection(!event.ShiftDown());
eventNav.SetWindowChange(event.ControlDown());
eventNav.SetEventObject(this);
if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
if (Navigate(!event.ShiftDown(), event.ControlDown()))
return;
}
}
else
{
// Insert tab since calling the default Windows handler
// doesn't seem to do it
WriteText(wxT("\t"));
}
break;
}