]> git.saurik.com Git - wxWidgets.git/commitdiff
With wxTE_PROCESS_TAB, tabs are now inserted in the text control
authorJulian Smart <julian@anthemion.co.uk>
Tue, 15 Jun 2004 14:03:06 +0000 (14:03 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Tue, 15 Jun 2004 14:03:06 +0000 (14:03 +0000)
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

docs/changes.txt
docs/latex/wx/window.tex
include/wx/window.h
src/common/wincmn.cpp
src/mac/carbon/textctrl.cpp
src/mac/classic/textctrl.cpp
src/msw/textctrl.cpp

index 6a0e2c0e397a9b0241b0159e81eaccb8c736d15e..b8ffe74ebc6bd4acc8c02d57f4b5bfc23fbf2838 100644 (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:
 
index 69b5779362ada9b808c1ab01039e61b978e8c720..24cb67196612b3c4d252f6052e115df8c2e213f9 100644 (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)
index 96385dd616fd2e99a9b1b4f0d5e510fb0703cbd0..3370fa75b28c033050202d985b64a053ddc29ca7 100644 (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
     // -------------------------
 
index d39583bbb8e2e2ab604fafa37f24c109d5cd8a25..382bcbec6d56060e892262aaf3da4eee2663433d 100644 (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
 // ----------------------------------------------------------------------------
index 6217f191c6953c1d748e7d69984bc74417d14079..eec92c414c277b2de0e143f8cac8abdeeb3c6b6a 100644 (file)
@@ -1985,21 +1985,10 @@ 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) )
+                if (Navigate(!event.ShiftDown(), event.ControlDown()))
                     return;
-
-                event.Skip() ;
-                return;
             }
             break;
     }
index fb63ab37866c72bf5bcb5555da2c5c5991427953..3819c0cd2e4d5028f5f5df1d5b9d4d128b61c79d 100644 (file)
@@ -1649,21 +1649,10 @@ 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) )
+                if (Navigate(!event.ShiftDown(), event.ControlDown()))
                     return;
-
-                event.Skip() ;
-                return;
             }
             break;
     }
index 5f85cb94b08afc60c635d2497bab75ea6ebde9da..82cc0b8e3ac05f0b8b1affeb5cdf8687a4f884a1 100644 (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,15 +1703,19 @@ 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 ( FindFocus() == this )
+            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;
+                if ( FindFocus() == this )
+                {
+                    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;
     }