Browse Source

Property grid navigation improvements.

* Do not handle tab key event when committing property changes so the
  property grid tab navigation works correctly.
* Do not call commit property changes on tab key when no changes are
  pending.
* Skip event handling in the base object value change and changing event
  handlers in case they do not get overloaded in derived objects.
* Do not force focus to canvas on property change so arrow and tab key
  grid navigation work properly.  Forcing the user to click the property
  grid control to edit a single property doesn't make sense.
* Pass properties panel show event up the event stack.
* Do not set focus to canvas in tool dispatcher if it already has the
  focus.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16957
fusion360
Wayne Stambaugh 2 years ago
parent
commit
8a1347d2c8
  1. 5
      common/tool/tool_dispatcher.cpp
  2. 7
      common/widgets/properties_panel.cpp
  3. 4
      common/widgets/properties_panel.h
  4. 11
      eeschema/widgets/sch_properties_panel.cpp
  5. 5
      pcbnew/widgets/pcb_properties_panel.cpp

5
common/tool/tool_dispatcher.cpp

@ -455,8 +455,11 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if( isMouseClick( type ) )
{
if( m_toolMgr->GetToolHolder() && m_toolMgr->GetToolHolder()->GetToolCanvas() )
if( m_toolMgr->GetToolHolder() && m_toolMgr->GetToolHolder()->GetToolCanvas() &&
!m_toolMgr->GetToolHolder()->GetToolCanvas()->HasFocus() )
{
m_toolMgr->GetToolHolder()->GetToolCanvas()->SetFocus();
}
}
// Mouse handling

7
common/widgets/properties_panel.cpp

@ -424,14 +424,19 @@ void PROPERTIES_PANEL::onShow( wxShowEvent& aEvent )
{
if( aEvent.IsShown() )
UpdateData();
aEvent.Skip();
}
void PROPERTIES_PANEL::onCharHook( wxKeyEvent& aEvent )
{
if( aEvent.GetKeyCode() == WXK_TAB && !aEvent.ShiftDown() )
if( aEvent.GetKeyCode() == WXK_TAB && !aEvent.ShiftDown() && m_grid->IsAnyModified() )
{
m_grid->CommitChangesFromEditor();
// Pass the tab key on so the default property grid tab behavior is honored.
aEvent.Skip();
return;
}

4
common/widgets/properties_panel.h

@ -78,8 +78,8 @@ protected:
virtual wxPGProperty* createPGProperty( const PROPERTY_BASE* aProperty ) const = 0;
// Event handlers
virtual void valueChanging( wxPropertyGridEvent& aEvent ) {}
virtual void valueChanged( wxPropertyGridEvent& aEvent ) {}
virtual void valueChanging( wxPropertyGridEvent& aEvent ) { aEvent.Skip(); }
virtual void valueChanged( wxPropertyGridEvent& aEvent ) { aEvent.Skip(); }
void onCharHook( wxKeyEvent& aEvent );
void onShow( wxShowEvent& aEvent );

11
eeschema/widgets/sch_properties_panel.cpp

@ -115,11 +115,6 @@ void SCH_PROPERTIES_PANEL::AfterCommit()
const SELECTION& selection = selectionTool->GetSelection();
rebuildProperties( selection );
CallAfter( [this]()
{
m_frame->GetCanvas()->SetFocus();
} );
}
@ -175,6 +170,8 @@ void SCH_PROPERTIES_PANEL::valueChanging( wxPropertyGridEvent& aEvent )
aEvent.Veto();
return;
}
aEvent.Skip();
}
@ -204,6 +201,8 @@ void SCH_PROPERTIES_PANEL::valueChanged( wxPropertyGridEvent& aEvent )
// Perform grid updates as necessary based on value change
AfterCommit();
aEvent.Skip();
}
@ -211,6 +210,8 @@ void SCH_PROPERTIES_PANEL::OnLanguageChanged( wxCommandEvent& aEvent )
{
PROPERTIES_PANEL::OnLanguageChanged( aEvent );
updateFontList();
aEvent.Skip();
}

5
pcbnew/widgets/pcb_properties_panel.cpp

@ -120,11 +120,6 @@ void PCB_PROPERTIES_PANEL::AfterCommit()
const SELECTION& selection = selectionTool->GetSelection();
rebuildProperties( selection );
CallAfter( [this]()
{
static_cast<PCB_EDIT_FRAME*>( m_frame )->GetCanvas()->SetFocus();
} );
}

Loading…
Cancel
Save