void OnMouseDoubleClick( wxMouseEvent &event );
void OnMouseUp( wxMouseEvent &event );
void OnKey( wxKeyEvent &event );
- void OnKeyUp( wxKeyEvent &event );
void OnResize( wxSizeEvent &event );
// event handlers
bool HandleMouseRightClick( int x, unsigned int y, wxMouseEvent &event );
bool HandleMouseDoubleClick( int x, unsigned int y, wxMouseEvent &event );
bool HandleMouseUp( int x, unsigned int y, wxMouseEvent &event );
- void HandleKeyEvent( wxKeyEvent &event );
- // Handle TAB and ESCAPE in control
- bool HandleChildKey( wxKeyEvent& event );
+ void HandleKeyEvent( wxKeyEvent &event, bool fromChild );
void OnMouseEntry( wxMouseEvent &event );
void OnMouseMoveChild( wxMouseEvent &event );
void OnMouseUpChild( wxMouseEvent &event );
void OnChildKeyDown( wxKeyEvent &event );
- void OnChildKeyUp( wxKeyEvent &event );
void OnCaptureChange( wxMouseCaptureChangedEvent &event );
void ImprovedClientToScreen( int* px, int* py );
+ // Returns True if editor control has focus
+ bool IsEditorFocused() const;
+
// Called by focus event handlers. newFocused is the window that becomes
// focused.
void HandleFocusChange( wxWindow* newFocused );
pg->OnKey( event );
}
- void OnKeyUp( wxKeyEvent& event )
- {
- wxPropertyGrid* pg = wxStaticCast(GetParent(), wxPropertyGrid);
- pg->OnKeyUp( event );
- }
-
void OnPaint( wxPaintEvent& event );
// Always be focussable, even with child windows
EVT_RIGHT_UP(wxPGCanvas::OnMouseRightClick)
EVT_LEFT_DCLICK(wxPGCanvas::OnMouseDoubleClick)
EVT_KEY_DOWN(wxPGCanvas::OnKey)
- EVT_KEY_UP(wxPGCanvas::OnKeyUp)
- EVT_CHAR(wxPGCanvas::OnKey)
END_EVENT_TABLE()
style |= wxVSCROLL;
-#ifdef __WXMSW__
- // This prevents crash under Win2K, but still
- // enables keyboard navigation
- if ( style & wxTAB_TRAVERSAL )
- {
- style &= ~(wxTAB_TRAVERSAL);
- style |= wxWANTS_CHARS;
- }
-#else
- if ( style & wxTAB_TRAVERSAL )
- style |= wxWANTS_CHARS;
-#endif
+ // Filter out wxTAB_TRAVERSAL - we will handle TABs manually
+ style &= ~(wxTAB_TRAVERSAL);
+ style |= wxWANTS_CHARS;
wxScrolledWindow::Create(parent,id,pos,size,style,name);
m_canvas = new wxPGCanvas();
m_canvas->Create(this, 1, wxPoint(0, 0), GetClientSize(),
- (GetWindowStyle() & wxTAB_TRAVERSAL) | wxWANTS_CHARS | wxCLIP_CHILDREN);
+ wxWANTS_CHARS | wxCLIP_CHILDREN);
m_canvas->SetBackgroundStyle( wxBG_STYLE_CUSTOM );
m_iFlags |= wxPG_FL_INITIALIZED;
}
}
-void wxPropertyGrid::HandleKeyEvent(wxKeyEvent &event)
+void wxPropertyGrid::HandleKeyEvent( wxKeyEvent &event, bool fromChild )
{
//
// Handles key event when editor control is not focused.
// Travelsal between items, collapsing/expanding, etc.
int keycode = event.GetKeyCode();
+ bool editorFocused = IsEditorFocused();
if ( keycode == WXK_TAB )
{
- if (m_selected)
- DoSelectProperty( m_selected, wxPG_SEL_FOCUS );
+ if ( !event.ShiftDown() )
+ {
+ if ( !editorFocused && m_wndEditor )
+ DoSelectProperty( m_selected, wxPG_SEL_FOCUS );
+ else
+ Navigate(wxNavigationKeyEvent::IsForward);
+ }
+ else
+ {
+ if ( editorFocused )
+ UnfocusEditor();
+ else
+ Navigate(wxNavigationKeyEvent::IsBackward);
+ }
+
return;
}
int secondAction;
int action = KeyEventToActions(event, &secondAction);
- if ( m_selected )
+ if ( editorFocused && action == wxPG_ACTION_CANCEL_EDIT )
{
+ //
+ // Esc cancels any changes
+ if ( IsEditorsValueModified() )
+ {
+ EditorsValueWasNotModified();
+ // Update the control as well
+ m_selected->GetEditorClass()->SetControlStringValue( m_selected,
+ GetEditorControl(),
+ m_selected->GetDisplayedString() );
+ }
+
+ OnValidationFailureReset(m_selected);
+
+ UnfocusEditor();
+ return;
+ }
+
+ // Except for TAB and ESC, handle child control events in child control
+ if ( fromChild )
+ return;
+
+ if ( m_selected )
+ {
// Show dialog?
if ( ButtonTriggerKeyTest(action, event) )
return;
{
selectDir = 1;
}
- else
- {
- event.Skip();
- }
-
}
if ( selectDir >= -1 )
// -----------------------------------------------------------------------
-// Potentially handles a keyboard event for editor controls.
-// Returns false if event should *not* be skipped (on true it can
-// be optionally skipped).
-// Basicly, false means that SelectProperty was called (or was about
-// to be called, if canDestroy was false).
-bool wxPropertyGrid::HandleChildKey( wxKeyEvent& event )
-{
- bool res = true;
-
- if ( !m_selected || !m_wndEditor )
- {
- return true;
- }
-
- int action = KeyEventToAction(event);
-
- // Unfocus?
- if ( action == wxPG_ACTION_CANCEL_EDIT )
- {
- //
- // Esc cancels any changes
- if ( IsEditorsValueModified() )
- {
- EditorsValueWasNotModified();
-
- // Update the control as well
- m_selected->GetEditorClass()->SetControlStringValue( m_selected,
- GetEditorControl(),
- m_selected->GetDisplayedString() );
- }
-
- OnValidationFailureReset(m_selected);
-
- res = false;
- UnfocusEditor();
- }
-
- return res;
-}
-
-// -----------------------------------------------------------------------
-
void wxPropertyGrid::OnKey( wxKeyEvent &event )
{
- HandleKeyEvent( event );
-}
-
-// -----------------------------------------------------------------------
-
-void wxPropertyGrid::OnKeyUp(wxKeyEvent &event)
-{
- event.Skip();
+ HandleKeyEvent(event, false);
}
// -----------------------------------------------------------------------
void wxPropertyGrid::OnChildKeyDown( wxKeyEvent &event )
{
- int keycode = event.GetKeyCode();
-
- // Ignore Alt and Control when they are down alone
- if ( keycode == WXK_ALT ||
- keycode == WXK_CONTROL )
- {
- event.Skip();
- return;
- }
-
- if ( ButtonTriggerKeyTest(-1, event) )
- return;
-
- if ( HandleChildKey(event) == true )
- event.Skip();
-
- GetEventHandler()->AddPendingEvent(event);
-}
-
-void wxPropertyGrid::OnChildKeyUp( wxKeyEvent &event )
-{
- GetEventHandler()->AddPendingEvent(event);
-
- event.Skip();
+ HandleKeyEvent(event, true);
}
// -----------------------------------------------------------------------
HandleFocusChange( newFocused );
}
+bool wxPropertyGrid::IsEditorFocused() const
+{
+ wxWindow* focus = wxWindow::FindFocus();
+
+ if ( focus == m_wndEditor || focus == m_wndEditor2 ||
+ focus == GetEditorControl() )
+ return true;
+
+ return false;
+}
+
// Called by focus event handlers. newFocused is the window that becomes focused.
void wxPropertyGrid::HandleFocusChange( wxWindow* newFocused )
{