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
This commit is contained in:
Wayne Stambaugh 2024-04-23 17:01:49 -04:00
parent 978ef352d0
commit 8a1347d2c8
5 changed files with 18 additions and 14 deletions

View File

@ -455,8 +455,11 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
if( isMouseClick( type ) ) 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(); m_toolMgr->GetToolHolder()->GetToolCanvas()->SetFocus();
}
} }
// Mouse handling // Mouse handling

View File

@ -424,14 +424,19 @@ void PROPERTIES_PANEL::onShow( wxShowEvent& aEvent )
{ {
if( aEvent.IsShown() ) if( aEvent.IsShown() )
UpdateData(); UpdateData();
aEvent.Skip();
} }
void PROPERTIES_PANEL::onCharHook( wxKeyEvent& aEvent ) 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(); m_grid->CommitChangesFromEditor();
// Pass the tab key on so the default property grid tab behavior is honored.
aEvent.Skip();
return; return;
} }

View File

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

View File

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

View File

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