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,9 +455,12 @@ 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
// Note: wxEVT_LEFT_DOWN event must always be skipped.

View File

@ -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;
}

View File

@ -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 );

View File

@ -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();
}

View File

@ -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();
} );
}