From 1766bf34538723bc34e5e963b6bacc5722b398ef Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Thu, 2 Oct 2008 16:02:20 +0000 Subject: [PATCH] SetButtonShortcut() merged with action system git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56035 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/propgrid/propgrid.h | 21 ++------------- src/propgrid/propgrid.cpp | 49 +++++++++------------------------- 2 files changed, 14 insertions(+), 56 deletions(-) diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 5c6cd03487..d16ad074ea 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -421,6 +421,7 @@ enum wxPG_KEYBOARD_ACTIONS wxPG_ACTION_CUT, wxPG_ACTION_COPY, wxPG_ACTION_PASTE, + wxPG_ACTION_PRESS_BUTTON, // Causes editor button (if any) to be pressed wxPG_ACTION_MAX }; @@ -934,15 +935,6 @@ public: return DoSelectProperty(p,focus?wxPG_SEL_FOCUS:0); } - /** Changes keyboard shortcut to push the editor button. - @remarks - You can set default with keycode 0. Good value for the platform is - guessed, but don't expect it to be very accurate. - */ - void SetButtonShortcut( int keycode, - bool ctrlDown = false, - bool altDown = false ); - /** Sets category caption background colour. */ void SetCaptionBackgroundColour(const wxColour& col); @@ -1483,9 +1475,6 @@ protected: int m_fontHeight; // Height of the font. - // Base keycode for triggering push button. - int m_pushButKeyCode; - /** m_splitterx when drag began. */ int m_startingSplitterX; @@ -1543,12 +1532,6 @@ protected: unsigned char m_vspacing; - // Does triggering push button need Alt down? - unsigned char m_pushButKeyCodeNeedsAlt; - - // Does triggering push button need Ctrl down? - unsigned char m_pushButKeyCodeNeedsCtrl; - // Used to track when Alt/Ctrl+Key was consumed. unsigned char m_keyComboConsumed; @@ -1829,7 +1812,7 @@ protected: private: - bool ButtonTriggerKeyTest( wxKeyEvent &event ); + bool ButtonTriggerKeyTest( int action, wxKeyEvent& event ); #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 969a92d08b..80d323e5e5 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -592,6 +592,7 @@ void wxPropertyGrid::Init1() AddActionTrigger( wxPG_ACTION_COPY, WXK_INSERT, wxMOD_CONTROL ); AddActionTrigger( wxPG_ACTION_PASTE, 'V', wxMOD_CONTROL ); AddActionTrigger( wxPG_ACTION_PASTE, WXK_INSERT, wxMOD_SHIFT ); + AddActionTrigger( wxPG_ACTION_PRESS_BUTTON, WXK_DOWN, wxMOD_ALT ); m_coloursCustomized = 0; m_frozen = 0; @@ -620,10 +621,6 @@ void wxPropertyGrid::Init1() m_width = m_height = 0; - SetButtonShortcut(0); - - m_keyComboConsumed = 0; - m_commonValues.push_back(new wxPGCommonValue(_("Unspecified"), wxPGGlobalVars->m_defaultRenderer) ); m_cvUnspecified = 0; @@ -2644,24 +2641,6 @@ wxPGProperty* wxPropertyGrid::GetNearestPaintVisible( wxPGProperty* p ) const } -// ----------------------------------------------------------------------- - -void wxPropertyGrid::SetButtonShortcut( int keycode, bool ctrlDown, bool altDown ) -{ - if ( keycode ) - { - m_pushButKeyCode = keycode; - m_pushButKeyCodeNeedsCtrl = ctrlDown ? 1 : 0; - m_pushButKeyCodeNeedsAlt = altDown ? 1 : 0; - } - else - { - m_pushButKeyCode = WXK_DOWN; - m_pushButKeyCodeNeedsCtrl = 0; - m_pushButKeyCodeNeedsAlt = 1; - } -} - // ----------------------------------------------------------------------- // Methods related to change in value, value modification and sending events // ----------------------------------------------------------------------- @@ -4999,7 +4978,7 @@ void wxPropertyGrid::HandleKeyEvent(wxKeyEvent &event) { // Show dialog? - if ( ButtonTriggerKeyTest(event) ) + if ( ButtonTriggerKeyTest(action, event) ) return; wxPGProperty* p = m_selected; @@ -5196,8 +5175,6 @@ void wxPropertyGrid::OnKey( wxKeyEvent &event ) void wxPropertyGrid::OnKeyUp(wxKeyEvent &event) { - m_keyComboConsumed = 0; - event.Skip(); } @@ -5285,19 +5262,19 @@ void wxPropertyGrid::OnNavigationKey( wxNavigationKeyEvent& event ) // ----------------------------------------------------------------------- -bool wxPropertyGrid::ButtonTriggerKeyTest( wxKeyEvent &event ) +bool wxPropertyGrid::ButtonTriggerKeyTest( int action, wxKeyEvent& event ) { - int keycode = event.GetKeyCode(); + if ( action == -1 ) + { + int secondAction; + action = KeyEventToActions(event, &secondAction); + } // Does the keycode trigger button? - if ( keycode == m_pushButKeyCode && - m_wndEditor2 && - (!m_pushButKeyCodeNeedsAlt || event.AltDown()) && - (!m_pushButKeyCodeNeedsCtrl || event.ControlDown()) ) + if ( action == wxPG_ACTION_PRESS_BUTTON && + m_wndEditor2 ) { - m_keyComboConsumed = 1; - - wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED,m_wndEditor2->GetId()); + wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, m_wndEditor2->GetId()); GetEventHandler()->AddPendingEvent(evt); return true; } @@ -5319,7 +5296,7 @@ void wxPropertyGrid::OnChildKeyDown( wxKeyEvent &event ) return; } - if ( ButtonTriggerKeyTest(event) ) + if ( ButtonTriggerKeyTest(-1, event) ) return; if ( HandleChildKey(event) == true ) @@ -5330,8 +5307,6 @@ void wxPropertyGrid::OnChildKeyDown( wxKeyEvent &event ) void wxPropertyGrid::OnChildKeyUp( wxKeyEvent &event ) { - m_keyComboConsumed = 0; - GetEventHandler()->AddPendingEvent(event); event.Skip();