tabbing in controls sample works again.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5609 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -38,26 +38,24 @@ class wxNotebookPage;
|
|||||||
class wxNotebook : public wxControl
|
class wxNotebook : public wxControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctors
|
// default for dynamic class
|
||||||
// -----
|
wxNotebook();
|
||||||
// default for dynamic class
|
// the same arguments as for wxControl
|
||||||
wxNotebook();
|
wxNotebook(wxWindow *parent,
|
||||||
// the same arguments as for wxControl (@@@ any special styles?)
|
|
||||||
wxNotebook(wxWindow *parent,
|
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = "notebook");
|
const wxString& name = "notebook");
|
||||||
// Create() function
|
// Create() function
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = "notebook");
|
const wxString& name = "notebook");
|
||||||
// dtor
|
// dtor
|
||||||
~wxNotebook();
|
~wxNotebook();
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
// ---------
|
// ---------
|
||||||
@@ -128,10 +126,9 @@ public:
|
|||||||
// get the panel which represents the given page
|
// get the panel which represents the given page
|
||||||
wxWindow *GetPage(int nPage) const;
|
wxWindow *GetPage(int nPage) const;
|
||||||
|
|
||||||
void OnNavigationKey(wxNavigationKeyEvent& event);
|
// handler for tab navigation
|
||||||
|
// --------------------------
|
||||||
// overridden from wxWindow to make tabbing work
|
void OnNavigationKey(wxNavigationKeyEvent& event);
|
||||||
void SetFocus();
|
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
// --------------
|
// --------------
|
||||||
|
@@ -38,26 +38,24 @@ class wxNotebookPage;
|
|||||||
class wxNotebook : public wxControl
|
class wxNotebook : public wxControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctors
|
// default for dynamic class
|
||||||
// -----
|
wxNotebook();
|
||||||
// default for dynamic class
|
// the same arguments as for wxControl
|
||||||
wxNotebook();
|
wxNotebook(wxWindow *parent,
|
||||||
// the same arguments as for wxControl (@@@ any special styles?)
|
|
||||||
wxNotebook(wxWindow *parent,
|
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = "notebook");
|
const wxString& name = "notebook");
|
||||||
// Create() function
|
// Create() function
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = 0,
|
long style = 0,
|
||||||
const wxString& name = "notebook");
|
const wxString& name = "notebook");
|
||||||
// dtor
|
// dtor
|
||||||
~wxNotebook();
|
~wxNotebook();
|
||||||
|
|
||||||
// accessors
|
// accessors
|
||||||
// ---------
|
// ---------
|
||||||
@@ -128,10 +126,9 @@ public:
|
|||||||
// get the panel which represents the given page
|
// get the panel which represents the given page
|
||||||
wxWindow *GetPage(int nPage) const;
|
wxWindow *GetPage(int nPage) const;
|
||||||
|
|
||||||
void OnNavigationKey(wxNavigationKeyEvent& event);
|
// handler for tab navigation
|
||||||
|
// --------------------------
|
||||||
// overridden from wxWindow to make tabbing work
|
void OnNavigationKey(wxNavigationKeyEvent& event);
|
||||||
void SetFocus();
|
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
// --------------
|
// --------------
|
||||||
|
@@ -384,7 +384,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
|||||||
m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE );
|
m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE );
|
||||||
// m_text->SetBackgroundColour("wheat");
|
// m_text->SetBackgroundColour("wheat");
|
||||||
|
|
||||||
//wxLog::AddTraceMask(_T("focus"));
|
wxLog::AddTraceMask(_T("focus"));
|
||||||
m_logTargetOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_text));
|
m_logTargetOld = wxLog::SetActiveTarget(new wxLogTextCtrl(m_text));
|
||||||
|
|
||||||
m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) );
|
m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) );
|
||||||
|
@@ -1622,8 +1622,9 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
{
|
{
|
||||||
wxNavigationKeyEvent nevent;
|
wxNavigationKeyEvent nevent;
|
||||||
nevent.SetDirection( !event.ShiftDown() );
|
nevent.SetDirection( !event.ShiftDown() );
|
||||||
|
nevent.SetEventObject( GetParent()->GetParent() );
|
||||||
nevent.SetCurrentFocus( m_parent );
|
nevent.SetCurrentFocus( m_parent );
|
||||||
if (m_parent->GetEventHandler()->ProcessEvent( nevent )) return;
|
if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent )) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no item -> nothing to do */
|
/* no item -> nothing to do */
|
||||||
|
@@ -227,14 +227,9 @@ void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
|
|||||||
if ( focussed_child_of_parent->IsTopLevel() )
|
if ( focussed_child_of_parent->IsTopLevel() )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// is the parent a panel?
|
event.SetCurrentFocus( focussed_child_of_parent );
|
||||||
wxPanel *panel = wxDynamicCast(parent, wxPanel);
|
if (parent->GetEventHandler()->ProcessEvent( event ))
|
||||||
if (panel)
|
return;
|
||||||
{
|
|
||||||
event.SetCurrentFocus( focussed_child_of_parent );
|
|
||||||
if (parent->GetEventHandler()->ProcessEvent( event ))
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
focussed_child_of_parent = parent;
|
focussed_child_of_parent = parent;
|
||||||
}
|
}
|
||||||
@@ -318,10 +313,7 @@ void wxPanel::SetFocus()
|
|||||||
// think my addition to OnNavigationKey() above takes care of it.
|
// think my addition to OnNavigationKey() above takes care of it.
|
||||||
// Keeping #ifdef __WXGTK__ for now, but please try removing it and see
|
// Keeping #ifdef __WXGTK__ for now, but please try removing it and see
|
||||||
// what happens.
|
// what happens.
|
||||||
|
// RR: Removed for now.
|
||||||
#ifdef __WXGTK__
|
|
||||||
m_winLastFocused = (wxWindow *)NULL;
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
if ( !SetFocusToChild() )
|
if ( !SetFocusToChild() )
|
||||||
{
|
{
|
||||||
@@ -331,7 +323,7 @@ void wxPanel::SetFocus()
|
|||||||
|
|
||||||
void wxPanel::OnFocus(wxFocusEvent& event)
|
void wxPanel::OnFocus(wxFocusEvent& event)
|
||||||
{
|
{
|
||||||
wxLogTrace(_T("focus"), _T("OnFocus on wxPanel 0x%08x."), GetHandle());
|
wxLogTrace(_T("focus"), _T("OnFocus on wxPanel 0x%08x, name: %s"), GetHandle(), GetName().c_str() );
|
||||||
|
|
||||||
// If the panel gets the focus *by way of getting clicked on*
|
// If the panel gets the focus *by way of getting clicked on*
|
||||||
// we move the focus to either the last window that had the
|
// we move the focus to either the last window that had the
|
||||||
|
@@ -153,6 +153,44 @@ gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// "key_press_event"
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static gint gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *win )
|
||||||
|
{
|
||||||
|
if (g_isIdle)
|
||||||
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
|
if (!win->m_hasVMT) return FALSE;
|
||||||
|
if (g_blockEventsOnDrag) return FALSE;
|
||||||
|
|
||||||
|
/* win is a control: tab can be propagated up */
|
||||||
|
if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab))
|
||||||
|
{
|
||||||
|
wxNode *node = win->m_pages.Nth( win->GetSelection() );
|
||||||
|
if (!node) return FALSE;
|
||||||
|
|
||||||
|
wxNotebookPage *page = (wxNotebookPage*) node->Data();
|
||||||
|
|
||||||
|
wxNavigationKeyEvent event;
|
||||||
|
event.SetEventObject( win );
|
||||||
|
/* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
|
||||||
|
event.SetDirection( (gdk_event->keyval == GDK_Tab) );
|
||||||
|
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||||
|
event.SetCurrentFocus( win );
|
||||||
|
if (!page->m_client->GetEventHandler()->ProcessEvent( event ))
|
||||||
|
{
|
||||||
|
page->m_client->SetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// InsertChild callback for wxNotebook
|
// InsertChild callback for wxNotebook
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -237,6 +275,9 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
|
|||||||
if (m_windowStyle & wxNB_BOTTOM)
|
if (m_windowStyle & wxNB_BOTTOM)
|
||||||
gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM );
|
gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM );
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
|
||||||
|
|
||||||
PostCreation();
|
PostCreation();
|
||||||
|
|
||||||
SetFont( parent->GetFont() );
|
SetFont( parent->GetFont() );
|
||||||
@@ -249,19 +290,6 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNotebook::SetFocus()
|
|
||||||
{
|
|
||||||
if (m_pages.GetCount() == 0) return;
|
|
||||||
|
|
||||||
wxNode *node = m_pages.Nth( GetSelection() );
|
|
||||||
|
|
||||||
if (!node) return;
|
|
||||||
|
|
||||||
wxNotebookPage *page = (wxNotebookPage*) node->Data();
|
|
||||||
|
|
||||||
page->m_client->SetFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxNotebook::GetSelection() const
|
int wxNotebook::GetSelection() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
|
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
|
||||||
|
@@ -778,13 +778,13 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
|||||||
(win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
|
(win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent new_event;
|
wxNavigationKeyEvent new_event;
|
||||||
new_event.SetEventObject( win );
|
new_event.SetEventObject( win->GetParent() );
|
||||||
/* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
|
/* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
|
||||||
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
|
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
|
||||||
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||||
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
|
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
|
||||||
new_event.SetCurrentFocus( win );
|
new_event.SetCurrentFocus( win );
|
||||||
ret = win->GetEventHandler()->ProcessEvent( new_event );
|
ret = win->GetParent()->GetEventHandler()->ProcessEvent( new_event );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generate wxID_CANCEL if <esc> has been pressed (typically in dialogs) */
|
/* generate wxID_CANCEL if <esc> has been pressed (typically in dialogs) */
|
||||||
|
@@ -153,6 +153,44 @@ gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// "key_press_event"
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static gint gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *win )
|
||||||
|
{
|
||||||
|
if (g_isIdle)
|
||||||
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
|
if (!win->m_hasVMT) return FALSE;
|
||||||
|
if (g_blockEventsOnDrag) return FALSE;
|
||||||
|
|
||||||
|
/* win is a control: tab can be propagated up */
|
||||||
|
if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab))
|
||||||
|
{
|
||||||
|
wxNode *node = win->m_pages.Nth( win->GetSelection() );
|
||||||
|
if (!node) return FALSE;
|
||||||
|
|
||||||
|
wxNotebookPage *page = (wxNotebookPage*) node->Data();
|
||||||
|
|
||||||
|
wxNavigationKeyEvent event;
|
||||||
|
event.SetEventObject( win );
|
||||||
|
/* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
|
||||||
|
event.SetDirection( (gdk_event->keyval == GDK_Tab) );
|
||||||
|
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||||
|
event.SetCurrentFocus( win );
|
||||||
|
if (!page->m_client->GetEventHandler()->ProcessEvent( event ))
|
||||||
|
{
|
||||||
|
page->m_client->SetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// InsertChild callback for wxNotebook
|
// InsertChild callback for wxNotebook
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -237,6 +275,9 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
|
|||||||
if (m_windowStyle & wxNB_BOTTOM)
|
if (m_windowStyle & wxNB_BOTTOM)
|
||||||
gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM );
|
gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM );
|
||||||
|
|
||||||
|
gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
|
||||||
|
GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
|
||||||
|
|
||||||
PostCreation();
|
PostCreation();
|
||||||
|
|
||||||
SetFont( parent->GetFont() );
|
SetFont( parent->GetFont() );
|
||||||
@@ -249,19 +290,6 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNotebook::SetFocus()
|
|
||||||
{
|
|
||||||
if (m_pages.GetCount() == 0) return;
|
|
||||||
|
|
||||||
wxNode *node = m_pages.Nth( GetSelection() );
|
|
||||||
|
|
||||||
if (!node) return;
|
|
||||||
|
|
||||||
wxNotebookPage *page = (wxNotebookPage*) node->Data();
|
|
||||||
|
|
||||||
page->m_client->SetFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
int wxNotebook::GetSelection() const
|
int wxNotebook::GetSelection() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
|
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
|
||||||
|
@@ -778,13 +778,13 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
|||||||
(win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
|
(win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent new_event;
|
wxNavigationKeyEvent new_event;
|
||||||
new_event.SetEventObject( win );
|
new_event.SetEventObject( win->GetParent() );
|
||||||
/* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
|
/* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
|
||||||
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
|
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
|
||||||
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||||
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
|
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
|
||||||
new_event.SetCurrentFocus( win );
|
new_event.SetCurrentFocus( win );
|
||||||
ret = win->GetEventHandler()->ProcessEvent( new_event );
|
ret = win->GetParent()->GetEventHandler()->ProcessEvent( new_event );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generate wxID_CANCEL if <esc> has been pressed (typically in dialogs) */
|
/* generate wxID_CANCEL if <esc> has been pressed (typically in dialogs) */
|
||||||
|
Reference in New Issue
Block a user