Try out our own tabbing logic.

Fixes: lp:1840991
* https://bugs.launchpad.net/kicad/+bug/1840991
This commit is contained in:
Jeff Young 2019-08-22 21:16:40 +01:00
parent 77488e379c
commit c85d1fa00c
3 changed files with 45 additions and 12 deletions

View File

@ -490,12 +490,43 @@ void DIALOG_SHIM::OnCharHook( wxKeyEvent& aEvt )
{
// shift-return (Mac default) or Ctrl-Return (GTK) for OK
if( aEvt.GetKeyCode() == WXK_RETURN && ( aEvt.ShiftDown() || aEvt.ControlDown() ) )
{
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
else
aEvt.Skip();
return;
}
else if( aEvt.GetKeyCode() == WXK_TAB && !aEvt.ControlDown() )
{
wxWindow* currentWindow = wxWindow::FindFocus();
int currentIdx = -1;
int delta = aEvt.ShiftDown() ? -1 : 1;
for( size_t i = 0; i < m_tabOrder.size(); ++i )
{
if( m_tabOrder[i] == currentWindow )
{
currentIdx = (int) i + delta;
if( currentIdx < 0 )
currentIdx = m_tabOrder.size() - 1;
else if ( currentIdx >= m_tabOrder.size() )
currentIdx = 0;
break;
}
}
if( currentIdx >= 0 )
{
m_tabOrder[ currentIdx ]->SetFocus();
return;
}
}
aEvt.Skip();
}
void DIALOG_SHIM::OnGridEditorShown( wxGridEvent& event )
{
SetEscapeId( wxID_NONE );

View File

@ -62,7 +62,7 @@ DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( LIB_EDIT_FRAME* parent, LIB_PIN* aPin
for ( unsigned ii = 0; ii < orientationNames.GetCount(); ii++ )
m_choiceOrientation->Insert( orientationNames[ii], KiBitmap( orientationBitmaps[ii] ), ii );
KIUI::SetControlsTabOrder( {
m_tabOrder = {
m_textPinName,
m_textPinNumber,
m_choiceElectricalType,
@ -73,7 +73,7 @@ DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN( LIB_EDIT_FRAME* parent, LIB_PIN* aPin
m_pinLengthCtrl,
m_nameSizeCtrl,
m_numberSizeCtrl
} );
};
m_sdbSizerButtonsOK->SetDefault();
SetInitialFocus( m_textPinName );

View File

@ -172,19 +172,21 @@ protected:
*/
int VertPixelsFromDU( int y );
EDA_UNITS_T m_units; // userUnits for display and parsing
std::string m_hash_key; // alternate for class_map when classname re-used
EDA_UNITS_T m_units; // userUnits for display and parsing
std::string m_hash_key; // alternate for class_map when classname re-used
// On MacOS (at least) SetFocus() calls made in the constructor will fail because a
// window that isn't yet visible will return false to AcceptsFocus(). So we must delay
// the initial-focus SetFocus() call to the first paint event.
bool m_firstPaintEvent;
wxWindow* m_initialFocusTarget;
bool m_firstPaintEvent;
wxWindow* m_initialFocusTarget;
// variables for quasi-modal behavior support, only used by a few derivatives.
WX_EVENT_LOOP* m_qmodal_loop; // points to nested event_loop, NULL means not qmodal and dismissed
bool m_qmodal_showing;
WDO_ENABLE_DISABLE* m_qmodal_parent_disabler;
WX_EVENT_LOOP* m_qmodal_loop; // points to nested event_loop, NULL means not qmodal
// and dismissed
bool m_qmodal_showing;
WDO_ENABLE_DISABLE* m_qmodal_parent_disabler;
std::vector<wxWindow*> m_tabOrder;
private:
void OnGridEditorShown( wxGridEvent& event );