Launch tools from Idle in the kicad manager.
Launching on a control event can allow that control to steal focus from the new windows as more events may exist intended for the control. Fix #4479
This commit is contained in:
parent
c56f616954
commit
a754bf6a48
|
@ -131,6 +131,7 @@ BEGIN_EVENT_TABLE( TREE_PROJECT_FRAME, wxSashLayoutWindow )
|
|||
EVT_MENU( ID_PROJECT_DELETE, TREE_PROJECT_FRAME::OnDeleteFile )
|
||||
EVT_MENU( ID_PROJECT_PRINT, TREE_PROJECT_FRAME::OnPrintFile )
|
||||
EVT_MENU( ID_PROJECT_RENAME, TREE_PROJECT_FRAME::OnRenameFile )
|
||||
EVT_IDLE( TREE_PROJECT_FRAME::OnIdle )
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
|
@ -141,6 +142,7 @@ TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent ) :
|
|||
m_Parent = parent;
|
||||
m_TreeProject = NULL;
|
||||
m_isRenaming = false;
|
||||
m_selectedItem = nullptr;
|
||||
|
||||
m_watcher = NULL;
|
||||
Connect( wxEVT_FSWATCHER,
|
||||
|
@ -905,7 +907,22 @@ void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )
|
|||
if( tree_data.size() != 1 )
|
||||
return;
|
||||
|
||||
tree_data[0]->Activate( this );
|
||||
// Bookmark the selected item but don't try and activate it until later
|
||||
// if we do it now, there will be more events at least on Windows in this frame
|
||||
// that will steal focus from any newly launched windows
|
||||
m_selectedItem = tree_data[0];
|
||||
}
|
||||
|
||||
|
||||
void TREE_PROJECT_FRAME::OnIdle( wxIdleEvent& aEvent )
|
||||
{
|
||||
// Idle executes once all other events finished processing
|
||||
// This makes it ideal to launch a new window without starting Focus wars.
|
||||
if( m_selectedItem != nullptr )
|
||||
{
|
||||
m_selectedItem->Activate( this );
|
||||
m_selectedItem = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ private:
|
|||
wxTreeItemId m_root;
|
||||
std::vector<wxString> m_filters;
|
||||
wxFileSystemWatcher* m_watcher; // file system watcher
|
||||
TREEPROJECT_ITEM* m_selectedItem;
|
||||
|
||||
public:
|
||||
TREE_PROJECT_FRAME( KICAD_MANAGER_FRAME* parent );
|
||||
|
@ -158,6 +159,12 @@ private:
|
|||
*/
|
||||
void OnSwitchToSelectedProject( wxCommandEvent& event );
|
||||
|
||||
/**
|
||||
* Idle event handler, used process the selected items at a point in time
|
||||
* when all other events have been consumed
|
||||
*/
|
||||
void OnIdle( wxIdleEvent &aEvent );
|
||||
|
||||
/**
|
||||
* Function AddItemToTreeProject
|
||||
* @brief Add the file or directory aName to the project tree
|
||||
|
|
Loading…
Reference in New Issue