dismissed immediately as text control grabbed the focus).
- wxPropertyGrid: added wxPG_EX_MULTIPLE_SELECTION.
- wxPropertyGrid: added functions for editing property labels.
+- wxPropertyGrid: Added wxPropertyGrid::DedicateKey().
- wxPropertyGridManager: added wxPG_NO_INTERNAL_BORDER,
wxPG_EX_NO_TOOLBAR_DIVIDER and wxPG_EX_TOOLBAR_SEPARATOR styles for finer
control over borders. Borders around property grid are now native for
/** Adds given key combination to trigger given action.
+ Here is a sample code to make Enter key press move focus to
+ the next property.
+
+ @code
+ propGrid->AddActionTrigger(wxPG_ACTION_NEXT_PROPERTY,
+ WXK_RETURN);
+ propGrid->DedicateKey(WXK_RETURN);
+ @endcode
+
@param action
Which action to trigger. See @link pgactions List of list of
wxPropertyGrid actions@endlink.
*/
void AddActionTrigger( int action, int keycode, int modifiers = 0 );
+ /**
+ Dedicates a specific keycode to wxPropertyGrid. This means that such
+ key presses will not be redirected to editor controls.
+
+ Using this function allows, for example, navigation between
+ properties using arrow keys even when the focus is in the editor
+ control.
+ */
+ void DedicateKey( int keycode )
+ {
+ m_dedicatedKeys.push_back(keycode);
+ }
+
/**
This static function enables or disables automatic use of
wxGetTranslation for following strings: wxEnumProperty list labels,
wxArrayPGProperty m_deletedProperties;
wxArrayPGProperty m_removedProperties;
+ /** List of key codes that will not be handed over to editor controls. */
+ // FIXME: Make this a hash set once there is template-based wxHashSet.
+ wxVector<int> m_dedicatedKeys;
+
//
// Temporary values
//
wxPGHashMapI2I,
class WXDLLIMPEXP_PROPGRID);
+// Utility to find if specific item is in a vector. Returns index to
+// the item, or wxNOT_FOUND if not present.
+template<typename CONTAINER, typename T>
+int wxPGFindInVector( CONTAINER vector, const T& item )
+{
+ for ( unsigned int i=0; i<vector.size(); i++ )
+ {
+ if ( vector[i] == item )
+ return (int) i;
+ }
+ return wxNOT_FOUND;
+}
+
// -----------------------------------------------------------------------
enum wxPG_GETPROPERTYVALUES_FLAGS
/**
Adds given key combination to trigger given action.
+ Here is a sample code to make Enter key press move focus to
+ the next property.
+
+ @code
+ propGrid->AddActionTrigger(wxPG_ACTION_NEXT_PROPERTY,
+ WXK_RETURN);
+ propGrid->DedicateKey(WXK_RETURN);
+ @endcode
+
@param action
Which action to trigger. See @ref propgrid_keyboard_actions.
@param keycode
long style = wxPG_DEFAULT_STYLE,
const wxChar* name = wxPropertyGridNameStr );
+ /**
+ Dedicates a specific keycode to wxPropertyGrid. This means that such
+ key presses will not be redirected to editor controls.
+
+ Using this function allows, for example, navigation between
+ properties using arrow keys even when the focus is in the editor
+ control.
+ */
+ void DedicateKey( int keycode );
+
/**
Enables or disables (shows/hides) categories according to parameter
enable.
ID_RUNMINIMAL,
ID_ENABLELABELEDITING,
ID_VETOCOLDRAG,
- ID_SHOWHEADER
+ ID_SHOWHEADER,
+ ID_ONEXTENDEDKEYNAV
};
// -----------------------------------------------------------------------
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 )
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();
// -----------------------------------------------------------------------
+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();
void OnIterate3Click( wxCommandEvent& event );
void OnIterate4Click( wxCommandEvent& event );
+ void OnExtendedKeyNav( wxCommandEvent& event );
+
void OnPropertyGridChange( wxPropertyGridEvent& event );
void OnPropertyGridChanging( wxPropertyGridEvent& event );
void OnPropertyGridSelect( wxPropertyGridEvent& event );
int wxPGProperty::Index( const wxPGProperty* p ) const
{
- for ( unsigned int i = 0; i<m_children.size(); i++ )
- {
- if ( p == m_children[i] )
- return i;
- }
- return wxNOT_FOUND;
+ return wxPGFindInVector(m_children, p);
}
bool wxPGProperty::ValidateValue( wxVariant& WXUNUSED(value), wxPGValidationInfo& WXUNUSED(validationInfo) ) const
{
int keycode = event.GetKeyCode();
+ // If key code was registered as action trigger, then trigger that action
if ( keycode == WXK_ESCAPE )
{
DoEndLabelEdit(false);
return;
}
- // Except for TAB and ESC, handle child control events in child control
- if ( fromChild )
+ // Except for TAB, ESC, and any keys specifically dedicated to
+ // wxPropertyGrid itself, handle child control events in child control.
+ if ( fromChild &&
+ wxPGFindInVector(m_dedicatedKeys, keycode) == wxNOT_FOUND )
{
// Only propagate event if it had modifiers
if ( !event.HasModifiers() )
{
p = wxPropertyGridIterator::OneStep( m_pState, wxPG_ITERATE_VISIBLE, p, selectDir );
if ( p )
- DoSelectProperty(p);
+ {
+ // If editor was focused, then make the next editor focused as well
+ int selFlags = 0;
+ if ( editorFocused )
+ selFlags |= wxPG_SEL_FOCUS;
+ DoSelectProperty(p, selFlags);
+ }
wasHandled = true;
}
}
bool wxPropertyGridPageState::DoIsPropertySelected( wxPGProperty* prop ) const
{
- const wxArrayPGProperty& selection = m_selection;
-
- for ( unsigned int i=0; i<selection.size(); i++ )
- {
- if ( selection[i] == prop )
- return true;
- }
+ if ( wxPGFindInVector(m_selection, prop) != wxNOT_FOUND )
+ return true;
return false;
}