Change default tool behaviour to skip unhandled events.
The problem is that wxEVT_CHAR_HOOK doesn’t do the key translation properly. wxEVT_CHAR does, but we only get to that if we skip the event at the end of the tool’s event processing loop, which most tools don’t do. (Selection tools, point editors, pickers, and a couple of others do skip, which is probably why this didn’t get reported earlier.) I played around with a couple of ways to fix wxEVT_CHAR_HOOK. Most of them don’t work, and the few egregious hacks I tried weren't cross- platform. So I’m changing it so that most tools now skip at the end of their event loops. I left out a couple that I felt were high risk (length tuning, for instance). But there’s still enough risk that I’m 100% sure it will break something, I just haven’t a clue what. Fixes: lp:1836903 * https://bugs.launchpad.net/kicad/+bug/1836903
This commit is contained in:
parent
815602d1af
commit
77334628c4
|
@ -212,6 +212,9 @@ int CVPCB_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
m_menu.ShowContextMenu( m_selection );
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
view.SetVisible( &ruler, false );
|
||||
|
|
|
@ -219,6 +219,9 @@ int LIB_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
m_view->AddToPreview( item->Clone() );
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Enable autopanning and cursor capture only when there is an item to be placed
|
||||
getViewControls()->SetAutoPan( item != nullptr );
|
||||
getViewControls()->CaptureCursor( item != nullptr );
|
||||
|
@ -371,6 +374,9 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Enable autopanning and cursor capture only when there is a shape being drawn
|
||||
getViewControls()->SetAutoPan( item != nullptr );
|
||||
getViewControls()->CaptureCursor( item != nullptr );
|
||||
|
@ -428,6 +434,8 @@ int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -258,6 +258,8 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
|
||||
break; // Finish
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
} while( ( evt = Wait() ) ); // Assignment intentional; not equality test
|
||||
|
||||
|
|
|
@ -221,6 +221,8 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
|||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( component->Clone() );
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Enable autopanning and cursor capture only when there is a module to be placed
|
||||
getViewControls()->SetAutoPan( component != nullptr );
|
||||
|
@ -372,6 +374,8 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
|||
m_view->AddToPreview( image->Clone() );
|
||||
m_view->RecacheAllItems(); // Bitmaps are cached in Opengl
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Enable autopanning and cursor capture only when there is a module to be placed
|
||||
getViewControls()->SetAutoPan( image != nullptr );
|
||||
|
@ -490,6 +494,8 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( previewItem->Clone() );
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
delete previewItem;
|
||||
|
@ -678,6 +684,8 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( item->Clone() );
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Enable autopanning and cursor capture only when there is a module to be placed
|
||||
getViewControls()->SetAutoPan( item != nullptr );
|
||||
|
@ -798,6 +806,8 @@ int SCH_DRAWING_TOOLS::DrawSheet( const TOOL_EVENT& aEvent )
|
|||
|
||||
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Enable autopanning and cursor capture only when there is a sheet to be placed
|
||||
getViewControls()->SetAutoPan( sheet != nullptr );
|
||||
|
|
|
@ -651,6 +651,8 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType,
|
|||
aSegment = doUnfoldBus( net );
|
||||
}
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Enable autopanning and cursor capture only when there is a segment to be placed
|
||||
getViewControls()->SetAutoPan( aSegment != nullptr );
|
||||
|
|
|
@ -409,6 +409,8 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
break; // Finish
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
controls->SetAutoPan( m_moveInProgress );
|
||||
|
||||
|
|
|
@ -678,6 +678,9 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
m_menu.ShowContextMenu( m_selection );
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
view.SetVisible( &ruler, false );
|
||||
|
|
|
@ -174,6 +174,8 @@ int PL_DRAWING_TOOLS::PlaceItem( const TOOL_EVENT& aEvent )
|
|||
item->SetPosition( item->GetPeer()->GetStartPosUi( 0 ) );
|
||||
getView()->Update( item );
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Enable autopanning and cursor capture only when there is an item to be placed
|
||||
getViewControls()->SetAutoPan( item != nullptr );
|
||||
|
@ -274,6 +276,9 @@ int PL_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
|||
m_menu.ShowContextMenu( m_selectionTool->GetSelection() );
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Enable autopanning and cursor capture only when there is a shape being drawn
|
||||
getViewControls()->SetAutoPan( item != nullptr );
|
||||
getViewControls()->CaptureCursor( item != nullptr );
|
||||
|
|
|
@ -220,6 +220,8 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
break; // Finish
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
} while( ( evt = Wait() ) ); //Should be assignment not equality test
|
||||
|
||||
|
|
|
@ -954,6 +954,18 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::layerToggle, true );
|
||||
}
|
||||
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
|
||||
{
|
||||
m_router->SwitchLayer( frame->GetActiveLayer() );
|
||||
updateStartItem( *evt );
|
||||
}
|
||||
else if( evt->IsKeyPressed() )
|
||||
{
|
||||
// wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
|
||||
// event so we need to process the wxEVT_CHAR event that will follow as long as we
|
||||
// pass the event.
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
if( m_cancelled )
|
||||
{
|
||||
|
|
|
@ -440,6 +440,9 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
|||
// Calling 'Properties' action clears the selection, so we need to restore it
|
||||
reselect = true;
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
frame()->SetMsgPanel( board() );
|
||||
|
@ -669,6 +672,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
|||
else
|
||||
frame()->SetMsgPanel( board() );
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
if( step != SET_ORIGIN )
|
||||
|
@ -816,6 +821,8 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
|
|||
commit.Push( _( "Place a DXF_SVG drawing" ) );
|
||||
break;
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
preview.Clear();
|
||||
|
@ -873,6 +880,8 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
|
|||
m_frame->PopTool( tool );
|
||||
break;
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1110,6 +1119,8 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, DRAWSEGMEN
|
|||
{
|
||||
isLocalOriginSet = true;
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
if( !isLocalOriginSet ) // reset the relative coordinte if it was not set before
|
||||
|
@ -1291,6 +1302,8 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, DRAWSEGMENT*& aGraphic, bo
|
|||
{
|
||||
arcManager.ToggleClockwise();
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
if( arcManager.IsComplete() )
|
||||
{
|
||||
|
@ -1538,6 +1551,9 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
|||
status.Hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
} // end while
|
||||
|
||||
m_controls->ForceCursorPosition( false );
|
||||
|
|
|
@ -473,6 +473,9 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
break; // Finish
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
} while( ( evt = Wait() ) ); //Should be assignment not equality test
|
||||
|
||||
m_lockedSelected = false;
|
||||
|
@ -1222,6 +1225,9 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
m_menu.ShowContextMenu();
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
view.SetVisible( &ruler, false );
|
||||
|
|
|
@ -254,6 +254,9 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
m_menu.ShowContextMenu( selection() );
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
controls.CaptureCursor( false );
|
||||
|
|
|
@ -488,6 +488,9 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
|
|||
m_menu.ShowContextMenu( selection() );
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Prepare the next loop by updating the old cursor mouse position
|
||||
// to this last mouse cursor position
|
||||
oldCursorPos = getViewControls()->GetCursorPosition();
|
||||
|
|
|
@ -759,6 +759,9 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
|
|||
reselect = true;
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
|
||||
// Enable autopanning and cursor capture only when there is a module to be placed
|
||||
controls->SetAutoPan( !!module );
|
||||
controls->CaptureCursor( !!module );
|
||||
|
@ -926,6 +929,9 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
|
|||
target->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
|
||||
view->Update( &preview );
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
preview.Clear();
|
||||
|
|
|
@ -207,6 +207,9 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool,
|
|||
// Show a preview of the item
|
||||
view()->Update( &preview );
|
||||
}
|
||||
|
||||
else
|
||||
evt->SetPassEvent();
|
||||
}
|
||||
|
||||
view()->Remove( &preview );
|
||||
|
|
Loading…
Reference in New Issue