- //
- // Esc cancels any changes
- if ( IsEditorsValueModified() )
- {
- EditorsValueWasNotModified();
-
- // Update the control as well
- m_selected->GetEditorClass()->SetControlStringValue( m_selected,
- m_wndEditor,
- m_selected->GetDisplayedString() );
- }
-
- OnValidationFailureReset(m_selected);
-
- res = false;
-
- UnfocusEditor();
- }
- else if ( action == wxPG_ACTION_COPY )
- {
- // NB: There is some problem with getting native cut-copy-paste keys to go through
- // for embedded editor wxTextCtrl. This is why we emulate.
- //
- wxTextCtrl* tc = GetEditorTextCtrl();
- if ( tc )
- {
- wxString sel = tc->GetStringSelection();
- if ( sel.length() )
- CopyTextToClipboard(sel);
- }
- else
- {
- CopyTextToClipboard(m_selected->GetDisplayedString());
- }
- }
- else if ( action == wxPG_ACTION_CUT )
- {
- wxTextCtrl* tc = GetEditorTextCtrl();
- if ( tc )
- {
- long from, to;
- tc->GetSelection(&from, &to);
- if ( from < to )
- {
- CopyTextToClipboard(tc->GetStringSelection());
- tc->Remove(from, to);
- }
- }
- }
- else if ( action == wxPG_ACTION_PASTE )
- {
- wxTextCtrl* tc = GetEditorTextCtrl();
- if ( tc )
- {
- if (wxTheClipboard->Open())
- {
- if (wxTheClipboard->IsSupported( wxDF_TEXT ))
- {
- wxTextDataObject data;
- wxTheClipboard->GetData( data );
- long from, to;
- tc->GetSelection(&from, &to);
- if ( from < to )
- {
- tc->Remove(from, to);
- tc->WriteText(data.GetText());
- }
- else
- {
- tc->WriteText(data.GetText());
- }
- }
- wxTheClipboard->Close();
- }
- }
- }
-
- return res;
-}
-
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::OnKey( wxKeyEvent &event )
-{
-
- //
- // Events to editor controls should get relayed here.
- //
- wxWindow* focused = wxWindow::FindFocus();
-
- wxWindow* primaryCtrl = GetEditorControl();
-
- if ( primaryCtrl &&
- (focused==primaryCtrl
- || m_editorFocused) )
- {
- // Child key must be processed here, since it can
- // destroy the control which is referred by its own
- // event handling.
- HandleChildKey( event );
- }
- else
- HandleKeyEvent( event );
-}
-
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::OnKeyUp(wxKeyEvent &event)
-{
- m_keyComboConsumed = 0;
-
- event.Skip();
-}
-
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::OnNavigationKey( wxNavigationKeyEvent& event )
-{
- // Ignore events that occur very close to focus set
- if ( m_iFlags & wxPG_FL_IGNORE_NEXT_NAVKEY )
- {
- m_iFlags &= ~(wxPG_FL_IGNORE_NEXT_NAVKEY);
- event.Skip();
- return;
- }
-
- wxPGProperty* next = (wxPGProperty*) NULL;
-
- int dir = event.GetDirection()?1:-1;
-
- if ( m_selected )
- {
- if ( dir == 1 && (m_wndEditor || m_wndEditor2) )
- {
- wxWindow* focused = wxWindow::FindFocus();
-
- wxWindow* wndToCheck = GetEditorControl();
-
- // ODComboBox focus goes to its text ctrl, so we need to use it instead
- if ( wndToCheck && wndToCheck->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)) )
- {
- wxTextCtrl* comboTextCtrl = ((wxOwnerDrawnComboBox*)wndToCheck)->GetTextCtrl();
- if ( comboTextCtrl )
- wndToCheck = comboTextCtrl;
- }
-
- /*
- // Because of problems navigating from wxButton, do not go to it.
- if ( !wndToCheck )
- {
- // No primary, use secondary
- wndToCheck = m_wndEditor2;
- }
- // If it has editor button, focus to it after the primary editor.
- // NB: Doesn't work since wxButton on wxMSW doesn't seem to propagate
- // key events (yes, I'm using wxWANTS_CHARS with it, and yes I
- // have somewhat debugged in window.cpp itself).
- else if ( focused == wndToCheck &&
- m_wndEditor2 &&
- !(GetExtraStyle() & wxPG_EX_NO_TAB_TO_BUTTON) )
- {
- wndToCheck = m_wndEditor2;
- wxLogDebug(wxT("Exp1"));
- }
- */
-
- if ( focused != wndToCheck &&
- wndToCheck )
- {
- wndToCheck->SetFocus();
-
- // Select all text in wxTextCtrl etc.
- if ( m_wndEditor && wndToCheck == m_wndEditor )
- m_selected->GetEditorClass()->OnFocus(m_selected,wndToCheck);
-
- m_editorFocused = 1;
- next = m_selected;
- }
- }
-
- if ( !next )
- {
- next = wxPropertyGridIterator::OneStep(m_pState, wxPG_ITERATE_VISIBLE, m_selected, dir);
-
- if ( next )
- {
- // This allows preventing NavigateOut to occur
- DoSelectProperty( next, wxPG_SEL_FOCUS );
- }
- }
- }
-
- if ( !next )
- event.Skip();
-}
-
-// -----------------------------------------------------------------------
-
-bool wxPropertyGrid::ButtonTriggerKeyTest( wxKeyEvent &event )
-{
- int keycode = event.GetKeyCode();