Work around focus issues for status popups.

Autoscroll wasn't working on Mac because the status popup's panel
has the focus.  This *may* also fix a problem on MSW of the auto-scroll
not being cancel-able.

Fixes https://gitlab.com/kicad/code/kicad/issues/11425
This commit is contained in:
Jeff Young 2022-09-04 21:04:17 +01:00
parent 9405817a4d
commit 895a8a8dbc
10 changed files with 44 additions and 16 deletions

View File

@ -67,7 +67,8 @@ EDA_DRAW_PANEL_GAL::EDA_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin
m_options( aOptions ),
m_eventDispatcher( nullptr ),
m_lostFocus( false ),
m_stealsFocus( true )
m_stealsFocus( true ),
m_statusPopup( nullptr )
{
m_parent = aParentWindow;
m_MouseCapturedLost = false;

View File

@ -507,8 +507,11 @@ void WX_VIEW_CONTROLS::onTimer( wxTimerEvent& aEvent )
return;
}
if( !m_parentPanel->HasFocus() )
break;
if( !m_parentPanel->HasFocus() && !m_parentPanel->StatusPopupHasFocus() )
{
m_state = IDLE;
return;
}
double borderSize = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().y );
@ -856,7 +859,6 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
}
return true;
break;
case IDLE:
if( borderHit )
@ -868,7 +870,6 @@ bool WX_VIEW_CONTROLS::handleAutoPanning( const wxMouseEvent& aEvent )
}
return false;
break;
case DRAG_PANNING:
case DRAG_ZOOMING:

View File

@ -42,8 +42,6 @@
#include <sch_base_frame.h>
#include <template_fieldnames.h>
class STATUS_TEXT_POPUP;
class SCH_ITEM;
class EDA_ITEM;
class SCH_LINE;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2018 CERN
* Copyright (C) 2013-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2013-2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch>
@ -88,7 +88,17 @@ public:
GAL_TYPE aGalType = GAL_TYPE_OPENGL );
~EDA_DRAW_PANEL_GAL();
virtual void SetFocus() override;
void SetFocus() override;
bool StatusPopupHasFocus()
{
return m_statusPopup && m_statusPopup->HasFocus();
}
void SetStatusPopup( wxWindow* aPopup )
{
m_statusPopup = aPopup;
}
/**
* Switch method of rendering graphics.
@ -292,6 +302,8 @@ protected:
/// and on various mouse/key events)
bool m_stealsFocus;
wxWindow* m_statusPopup;
/// Optional overlay for drawing transient debug objects
std::shared_ptr<KIGFX::VIEW_OVERLAY> m_debugOverlay;
};

View File

@ -59,6 +59,8 @@ public:
*/
void Expire( int aMsecs );
wxWindow* GetPanel() { return m_panel; }
protected:
void updateSize();
@ -67,9 +69,10 @@ protected:
///< Expire timer even handler
void onExpire( wxTimerEvent& aEvent );
wxPanel* m_panel;
protected:
wxPanel* m_panel;
wxBoxSizer* m_topSizer;
wxTimer m_expireTimer;
wxTimer m_expireTimer;
};

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router
*
* Copyright (C) 2013-2017 CERN
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
@ -19,7 +19,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "class_draw_panel_gal.h"
#include <class_draw_panel_gal.h>
#include <dialogs/dialog_pns_length_tuning_settings.h>
#include <tool/tool_manager.h>
#include <tools/pcb_actions.h>
@ -166,6 +166,7 @@ void LENGTH_TUNER_TOOL::performTuning()
// Create an instance of PNS_TUNE_STATUS_POPUP.
PNS_TUNE_STATUS_POPUP statusPopup( frame() );
statusPopup.Popup();
canvas()->SetStatusPopup( statusPopup.GetPanel() );
m_router->Move( end, nullptr );
updateStatusPopup( statusPopup );
@ -243,6 +244,7 @@ void LENGTH_TUNER_TOOL::performTuning()
m_router->StopRouting();
frame()->UndoRedoBlock( false );
canvas()->SetStatusPopup( nullptr );
controls()->SetAutoPan( false );
controls()->ForceCursorPosition( false );
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );

View File

@ -113,7 +113,7 @@ bool EDIT_TOOL::Init()
{
if( getView()->IsLayerVisible( LAYER_SCHEMATIC_DRAWINGSHEET ) )
{
DS_PROXY_VIEW_ITEM* ds = frame()->GetCanvas()->GetDrawingSheet();
DS_PROXY_VIEW_ITEM* ds = canvas()->GetDrawingSheet();
VECTOR2D cursor = getViewControls()->GetCursorPosition( false );
if( ds && ds->HitTestDrawingSheetItems( getView(), cursor ) )
@ -2032,6 +2032,7 @@ bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aS
m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
m_statusPopup->Popup();
canvas()->SetStatusPopup( m_statusPopup->GetPanel() );
std::string tool = "";
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
@ -2046,6 +2047,7 @@ bool EDIT_TOOL::pickReferencePoint( const wxString& aTooltip, const wxString& aS
}
// Ensure statusPopup is hidden after use and before deleting it:
canvas()->SetStatusPopup( nullptr );
m_statusPopup->Hide();
if( pickedPoint )

View File

@ -193,6 +193,7 @@ int GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent )
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
statusPopup.Popup();
canvas()->SetStatusPopup( statusPopup.GetPanel() );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
@ -205,6 +206,8 @@ int GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent )
break;
}
canvas()->SetStatusPopup( nullptr );
return 0;
}

View File

@ -320,7 +320,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
auto setCursor =
[&]()
{
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
canvas()->SetCurrentCursor( KICURSOR::BULLSEYE );
};
Activate();
@ -335,6 +335,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
statusPopup.SetText( wxString::Format( msg, padPrefix, seqPadNum ) );
statusPopup.Popup();
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
canvas()->SetStatusPopup( statusPopup.GetPanel() );
while( TOOL_EVENT* evt = Wait() )
{
@ -475,8 +476,10 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
getView()->Update( p );
}
canvas()->SetStatusPopup( nullptr );
statusPopup.Hide();
frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
canvas()->SetCurrentCursor( KICURSOR::ARROW );
getViewControls()->ForceCursorPosition( false );
return 0;
}

View File

@ -220,6 +220,7 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
statusPopup.Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
statusPopup.Popup();
canvas()->SetStatusPopup( statusPopup.GetPanel() );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );
@ -232,6 +233,8 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
break;
}
canvas()->SetStatusPopup( nullptr );
return 0;
}