From eedc82f4e96c7f8f0b24addbfd6b4429c9587631 Mon Sep 17 00:00:00 2001
From: Julian Smart <julian@anthemion.co.uk>
Date: Tue, 15 Jun 2004 21:55:18 +0000
Subject: [PATCH] Navigate corrections

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27815 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/window.tex     | 6 ++----
 include/wx/window.h          | 2 +-
 src/common/wincmn.cpp        | 5 ++---
 src/gtk/window.cpp           | 4 ++--
 src/gtk1/window.cpp          | 4 ++--
 src/mac/carbon/textctrl.cpp  | 7 ++++++-
 src/mac/classic/textctrl.cpp | 7 ++++++-
 src/msw/textctrl.cpp         | 7 ++++++-
 8 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/docs/latex/wx/window.tex b/docs/latex/wx/window.tex
index 24cb671966..e32ce366dd 100644
--- a/docs/latex/wx/window.tex
+++ b/docs/latex/wx/window.tex
@@ -1450,16 +1450,14 @@ implements the following methods:\par
 
 \membersection{wxWindow::Navigate}\label{wxwindownavigate}
 
-\func{bool}{Navigate}{\param{bool}{ direction = true}, \param{bool}{ windowChange = false}}
+\func{bool}{Navigate}{\param{int}{ flags = wxNavigationKeyEvent::IsForward}}
 
 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.}
+\docparam{flags}{A combination of wxNavigationKeyEvent::IsForward and wxNavigationKeyEvent::WinChange.}
 
 \wxheading{Remarks}
 
diff --git a/include/wx/window.h b/include/wx/window.h
index 3370fa75b2..8b53af60c0 100644
--- a/include/wx/window.h
+++ b/include/wx/window.h
@@ -490,7 +490,7 @@ public:
     virtual void SetTmpDefaultItem(wxWindow * WXUNUSED(win)) { }
 
         // Navigates in the specified direction by sending a wxNavigationKeyEvent
-    virtual bool Navigate(bool direction = true, bool windowChange = false);
+    virtual bool Navigate(int flags = wxNavigationKeyEvent::IsForward);
 
     // parent/children relations
     // -------------------------
diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp
index 382bcbec6d..5ba278de5f 100644
--- a/src/common/wincmn.cpp
+++ b/src/common/wincmn.cpp
@@ -2405,11 +2405,10 @@ bool wxWindowBase::TryParent(wxEvent& event)
 // ----------------------------------------------------------------------------
 
 // Navigates in the specified direction.
-bool wxWindowBase::Navigate(bool direction, bool windowChange)
+bool wxWindowBase::Navigate(int flags)
 {
     wxNavigationKeyEvent eventNav;
-    eventNav.SetDirection(direction);
-    eventNav.SetWindowChange(windowChange);
+    eventNav.SetFlags(flags);
     eventNav.SetEventObject(this);
     if ( GetParent()->GetEventHandler()->ProcessEvent(eventNav) )
     {
diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp
index 82cdcb61f2..b000562cc0 100644
--- a/src/gtk/window.cpp
+++ b/src/gtk/window.cpp
@@ -1197,8 +1197,8 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
 // JS: enabling again to make consistent with other platforms
 //     (with wxTE_PROCESS_TAB you have to call Navigate to get default
 //     navigation behaviour)
-#if 1
-         !win->HasFlag(wxTE_PROCESS_TAB) &&
+#if wxUSE_TEXTCTRL
+         (! (win->HasFlag(wxTE_PROCESS_TAB) && IsKindOf(CLASSINFO(wxTextCtrl)) )) &&
 #endif
          win->GetParent() && (win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
     {
diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp
index 82cdcb61f2..b000562cc0 100644
--- a/src/gtk1/window.cpp
+++ b/src/gtk1/window.cpp
@@ -1197,8 +1197,8 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
 // JS: enabling again to make consistent with other platforms
 //     (with wxTE_PROCESS_TAB you have to call Navigate to get default
 //     navigation behaviour)
-#if 1
-         !win->HasFlag(wxTE_PROCESS_TAB) &&
+#if wxUSE_TEXTCTRL
+         (! (win->HasFlag(wxTE_PROCESS_TAB) && IsKindOf(CLASSINFO(wxTextCtrl)) )) &&
 #endif
          win->GetParent() && (win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
     {
diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp
index 86d6e450d4..b1ae31ebe5 100644
--- a/src/mac/carbon/textctrl.cpp
+++ b/src/mac/carbon/textctrl.cpp
@@ -1987,7 +1987,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
         case WXK_TAB:
             if ( !(m_windowStyle & wxTE_PROCESS_TAB))
             {
-                Navigate(!event.ShiftDown(), event.ControlDown());
+                int flags = 0;
+                if (!event.ShiftDown())
+                    flags |= wxNavigationKeyEvent::IsForward ;
+                if (event.ControlDown())
+                    flags |= wxNavigationKeyEvent::WinChange ;
+                Navigate(flags);
                 return;
             }
             else
diff --git a/src/mac/classic/textctrl.cpp b/src/mac/classic/textctrl.cpp
index 18ebe8307f..078f722035 100644
--- a/src/mac/classic/textctrl.cpp
+++ b/src/mac/classic/textctrl.cpp
@@ -1651,7 +1651,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
         case WXK_TAB:
             if ( !(m_windowStyle & wxTE_PROCESS_TAB))
             {
-                Navigate(!event.ShiftDown(), event.ControlDown());
+                int flags = 0;
+                if (!event.ShiftDown())
+                    flags |= wxNavigationKeyEvent::IsForward ;
+                if (event.ControlDown())
+                    flags |= wxNavigationKeyEvent::WinChange ;
+                Navigate(flags);
                 return;
             }
             else
diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp
index 82cc0b8e3a..c4c015a3df 100644
--- a/src/msw/textctrl.cpp
+++ b/src/msw/textctrl.cpp
@@ -1707,7 +1707,12 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
             {
                 if ( FindFocus() == this )
                 {
-                    if (Navigate(!event.ShiftDown(), event.ControlDown()))
+                    int flags = 0;
+                    if (!event.ShiftDown())
+                        flags |= wxNavigationKeyEvent::IsForward ;
+                    if (event.ControlDown())
+                        flags |= wxNavigationKeyEvent::WinChange ;
+                    if (Navigate(flags))
                         return;
                 }
             }
-- 
2.50.0

