Added wxPropertyGrid::DedicateKey(), which prevents specific key presses from being eaten by editor controls. This is useful for customizing keyboard navigation. Also added utility function wxPGFindInVector<>(), which is used in the new code, and also in some other places.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64562 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli
2010-06-12 09:30:57 +00:00
parent b589082adc
commit 8d2c70414c
9 changed files with 103 additions and 17 deletions

View File

@@ -691,7 +691,8 @@ enum
ID_RUNMINIMAL,
ID_ENABLELABELEDITING,
ID_VETOCOLDRAG,
ID_SHOWHEADER
ID_SHOWHEADER,
ID_ONEXTENDEDKEYNAV
};
// -----------------------------------------------------------------------
@@ -756,6 +757,7 @@ BEGIN_EVENT_TABLE(FormMain, wxFrame)
EVT_MENU( ID_ITERATE2, FormMain::OnIterate2Click )
EVT_MENU( ID_ITERATE3, FormMain::OnIterate3Click )
EVT_MENU( ID_ITERATE4, FormMain::OnIterate4Click )
EVT_MENU( ID_ONEXTENDEDKEYNAV, FormMain::OnExtendedKeyNav )
EVT_MENU( ID_SETBGCOLOUR, FormMain::OnSetBackgroundColour )
EVT_MENU( ID_SETBGCOLOURRECUR, FormMain::OnSetBackgroundColour )
EVT_MENU( ID_CLEARMODIF, FormMain::OnClearModifyStatusClick )
@@ -2308,6 +2310,11 @@ FormMain::FormMain(const wxString& title, const wxPoint& pos, const wxSize& size
menuTools2->Append(ID_ITERATE3, wxT("Reverse Iterate Over Properties") );
menuTools2->Append(ID_ITERATE4, wxT("Iterate Over Categories") );
menuTools2->AppendSeparator();
menuTools2->Append(ID_ONEXTENDEDKEYNAV, "Extend Keyboard Navigation",
"This will set Enter to navigate to next property, "
"and allows arrow keys to navigate even when in "
"editor control.");
menuTools2->AppendSeparator();
menuTools2->Append(ID_SETPROPERTYVALUE, wxT("Set Property Value") );
menuTools2->Append(ID_CLEARMODIF, wxT("Clear Modified Status"), wxT("Clears wxPG_MODIFIED flag from all properties.") );
menuTools2->AppendSeparator();
@@ -2684,6 +2691,25 @@ void FormMain::OnIterate4Click( wxCommandEvent& WXUNUSED(event) )
// -----------------------------------------------------------------------
void FormMain::OnExtendedKeyNav( wxCommandEvent& WXUNUSED(event) )
{
// Use AddActionTrigger() and DedicateKey() to set up Enter,
// Up, and Down keys for navigating between properties.
wxPropertyGrid* propGrid = m_pPropGridManager->GetGrid();
propGrid->AddActionTrigger(wxPG_ACTION_NEXT_PROPERTY,
WXK_RETURN);
propGrid->DedicateKey(WXK_RETURN);
// Up and Down keys are alredy associated with navigation,
// but we must also prevent them from being eaten by
// editor controls.
propGrid->DedicateKey(WXK_UP);
propGrid->DedicateKey(WXK_DOWN);
}
// -----------------------------------------------------------------------
void FormMain::OnFitColumnsClick( wxCommandEvent& WXUNUSED(event) )
{
wxPropertyGridPage* page = m_pPropGridManager->GetCurrentPage();