Supported navigation between documents with keyboard

This commit is contained in:
Zane U. Ji 2012-08-15 21:43:31 +08:00
parent 47dbfafd71
commit 0263408aef
4 changed files with 41 additions and 6 deletions

View File

@ -27,6 +27,7 @@ BEGIN_EVENT_TABLE ( MyNotebook, wxAuiNotebook )
EVT_RIGHT_DOWN ( MyNotebook::OnRightDown ) EVT_RIGHT_DOWN ( MyNotebook::OnRightDown )
EVT_MENU ( ID_MENU_CLOSE, MyNotebook::OnMenuClose ) EVT_MENU ( ID_MENU_CLOSE, MyNotebook::OnMenuClose )
EVT_MENU ( ID_MENU_CLOSE_ALL, MyNotebook::OnMenuCloseAll ) EVT_MENU ( ID_MENU_CLOSE_ALL, MyNotebook::OnMenuCloseAll )
//EVT_KEY_DOWN ( MyNotebook::OnKeyDown )
END_EVENT_TABLE() END_EVENT_TABLE()
MyNotebook::MyNotebook ( MyNotebook::MyNotebook (
@ -37,6 +38,9 @@ MyNotebook::MyNotebook (
int style ) : wxAuiNotebook ( parent, id, position, size, style ) int style ) : wxAuiNotebook ( parent, id, position, size, style )
{ {
rightClickPage = -1; rightClickPage = -1;
wxApp::GetInstance()->Connect ( wxEVT_KEY_DOWN,
wxKeyEventHandler ( MyNotebook::OnKeyDown ), NULL, this );
} }
void MyNotebook::OnLeftDown ( wxMouseEvent& event ) void MyNotebook::OnLeftDown ( wxMouseEvent& event )
@ -104,3 +108,24 @@ void MyNotebook::OnMenuCloseAll ( wxCommandEvent& WXUNUSED ( event ) )
wxCommandEvent e; wxCommandEvent e;
frame->OnCloseAll ( e ); frame->OnCloseAll ( e );
} }
void MyNotebook::OnKeyDown ( wxKeyEvent &event )
{
#if defined __WXGTK__
if ( event.m_keyCode != WXK_TAB || !event.m_altDown )
#elif defined __WXOSX__
if ( event.m_uniChar != ',' || !event.m_controlDown )
#else
if ( event.m_keyCode != WXK_TAB || !event.m_controlDown )
#endif
{
event.Skip();
return;
}
AdvanceSelection ( !event.m_shiftDown );
XmlDoc *doc = ( XmlDoc * ) GetCurrentPage();
if ( doc != NULL )
doc->SetFocus();
}

View File

@ -43,6 +43,7 @@ class MyNotebook : public wxAuiNotebook
void OnRightDown ( wxMouseEvent& event ); void OnRightDown ( wxMouseEvent& event );
void OnMenuClose ( wxCommandEvent& event ); void OnMenuClose ( wxCommandEvent& event );
void OnMenuCloseAll ( wxCommandEvent& event ); void OnMenuCloseAll ( wxCommandEvent& event );
void OnKeyDown ( wxKeyEvent &event );
private: private:
int rightClickPage; int rightClickPage;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@ -592,18 +592,18 @@ MyFrame::MyFrame (
mainBook ( 0 ), mainBook ( 0 ),
restoreFocusToNotebook ( false ) restoreFocusToNotebook ( false )
{ {
#ifdef __WXDEBUG__
wxLog::SetActiveTarget ( &logTarget );
wxLog::SetLogLevel ( wxLOG_Max );
#endif
manager.SetManagedWindow ( this ); manager.SetManagedWindow ( this );
lastPos = 0; lastPos = 0;
htmlReport = NULL; htmlReport = NULL;
lastDoc = NULL; lastDoc = NULL;
wxString defaultFont = wxString defaultFont = wxSystemSettings::GetFont ( wxSYS_SYSTEM_FONT ).GetFaceName();
#ifdef __WXMSW__
_T ( "Arial" );
#else
_T ( "Bitstream Vera Sans" );
#endif
bool findMatchCase; bool findMatchCase;
@ -850,6 +850,7 @@ MyFrame::MyFrame (
long style = wxAUI_NB_TOP | long style = wxAUI_NB_TOP |
wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_SPLIT |
wxAUI_NB_TAB_MOVE | wxAUI_NB_TAB_MOVE |
wxAUI_NB_SCROLL_BUTTONS |
wxAUI_NB_WINDOWLIST_BUTTON | wxAUI_NB_WINDOWLIST_BUTTON |
wxAUI_NB_CLOSE_ON_ALL_TABS | wxAUI_NB_CLOSE_ON_ALL_TABS |
wxNO_BORDER; wxNO_BORDER;
@ -987,6 +988,10 @@ MyFrame::MyFrame (
MyFrame::~MyFrame() MyFrame::~MyFrame()
{ {
#ifdef __WXDEBUG__
wxLog::SetActiveTarget ( NULL );
#endif
std::vector<wxString>::iterator it; std::vector<wxString>::iterator it;
for ( it = tempFileVector.begin(); it != tempFileVector.end(); it++ ) for ( it = tempFileVector.begin(); it != tempFileVector.end(); it++ )
wxRemoveFile ( *it ); wxRemoveFile ( *it );

View File

@ -345,7 +345,11 @@ class MyFrame : public wxFrame
wxLocale& myLocale; wxLocale& myLocale;
bool singleInstanceCheck; bool singleInstanceCheck;
int lang, lastPos; int lang, lastPos;
#ifdef __WXDEBUG__
wxLogStderr logTarget;
#else
wxLogNull logTarget; wxLogNull logTarget;
#endif
std::auto_ptr<wxHtmlEasyPrinting> htmlPrinting; std::auto_ptr<wxHtmlEasyPrinting> htmlPrinting;
std::auto_ptr<wxFindReplaceDialog> findDialog; std::auto_ptr<wxFindReplaceDialog> findDialog;
std::auto_ptr<wxHtmlHelpController> helpController; std::auto_ptr<wxHtmlHelpController> helpController;