A fuller implementation of allowing cut/copy/paste in search boxes.
This one also works for other text entry widgets, and also works for other frames.
This commit is contained in:
parent
b9ac4f2ac9
commit
12a75ffb94
|
@ -379,6 +379,9 @@ void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAM
|
|||
bool checkRes = false;
|
||||
bool enableRes = true;
|
||||
bool showRes = true;
|
||||
bool isCut = aEvent.GetId() == ACTIONS::cut.GetUIId();
|
||||
bool isCopy = aEvent.GetId() == ACTIONS::copy.GetUIId();
|
||||
bool isPaste = aEvent.GetId() == ACTIONS::paste.GetUIId();
|
||||
SELECTION& selection = aFrame->GetCurrentSelection();
|
||||
|
||||
try
|
||||
|
@ -394,6 +397,19 @@ void EDA_BASE_FRAME::HandleUpdateUIEvent( wxUpdateUIEvent& aEvent, EDA_BASE_FRAM
|
|||
return;
|
||||
}
|
||||
|
||||
if( isCut || isCopy || isPaste )
|
||||
{
|
||||
wxWindow* focus = wxWindow::FindFocus();
|
||||
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( focus );
|
||||
|
||||
if( textEntry && isCut && textEntry->CanCut() )
|
||||
enableRes = true;
|
||||
else if( textEntry && isCopy && textEntry->CanCopy() )
|
||||
enableRes = true;
|
||||
else if( textEntry && isPaste && textEntry->CanPaste() )
|
||||
enableRes = true;
|
||||
}
|
||||
|
||||
aEvent.Enable( enableRes );
|
||||
aEvent.Show( showRes );
|
||||
|
||||
|
|
|
@ -348,12 +348,6 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
|
|||
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )
|
||||
#define CHECK( x ) ACTION_CONDITIONS().Check( x )
|
||||
|
||||
auto searchHasFocus =
|
||||
[this]( const SELECTION& )
|
||||
{
|
||||
return m_treePane->GetLibTree()->GetFocusTarget()->HasFocus();
|
||||
};
|
||||
|
||||
auto haveSymbolCond =
|
||||
[this]( const SELECTION& )
|
||||
{
|
||||
|
@ -410,10 +404,9 @@ void SYMBOL_EDIT_FRAME::setupUIConditions()
|
|||
mgr->SetConditions( ACTIONS::inchesUnits, CHECK( cond.Units( EDA_UNITS::INCHES ) ) );
|
||||
mgr->SetConditions( ACTIONS::milsUnits, CHECK( cond.Units( EDA_UNITS::MILS ) ) );
|
||||
|
||||
mgr->SetConditions( ACTIONS::cut, ENABLE( isEditableCond || searchHasFocus ) );
|
||||
mgr->SetConditions( ACTIONS::copy, ENABLE( haveSymbolCond || searchHasFocus ) );
|
||||
mgr->SetConditions( ACTIONS::paste, ENABLE( ( isEditableCond && SELECTION_CONDITIONS::Idle )
|
||||
|| searchHasFocus ) );
|
||||
mgr->SetConditions( ACTIONS::cut, ENABLE( isEditableCond ) );
|
||||
mgr->SetConditions( ACTIONS::copy, ENABLE( haveSymbolCond ) );
|
||||
mgr->SetConditions( ACTIONS::paste, ENABLE( isEditableCond && SELECTION_CONDITIONS::Idle ) );
|
||||
mgr->SetConditions( ACTIONS::doDelete, ENABLE( isEditableCond ) );
|
||||
mgr->SetConditions( ACTIONS::duplicate, ENABLE( isEditableCond ) );
|
||||
mgr->SetConditions( ACTIONS::selectAll, ENABLE( haveSymbolCond ) );
|
||||
|
|
Loading…
Reference in New Issue