Remove unneeded state member in DIALOG_CHOOSE_COMPONENT

This commit is contained in:
Chris Pavlina 2017-02-23 20:59:15 -05:00
parent 2683af26c0
commit d3cb23b7d7
2 changed files with 19 additions and 21 deletions

View File

@ -51,7 +51,6 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const
m_parent = aParent; m_parent = aParent;
m_deMorganConvert = aDeMorganConvert >= 0 ? aDeMorganConvert : 0; m_deMorganConvert = aDeMorganConvert >= 0 ? aDeMorganConvert : 0;
m_external_browser_requested = false; m_external_browser_requested = false;
m_received_doubleclick_in_tree = false;
m_search_container->SetTree( m_libraryComponentTree ); m_search_container->SetTree( m_libraryComponentTree );
m_componentView->SetLayoutDirection( wxLayout_LeftToRight ); m_componentView->SetLayoutDirection( wxLayout_LeftToRight );
m_dbl_click_timer = std::make_unique<wxTimer>( this ); m_dbl_click_timer = std::make_unique<wxTimer>( this );
@ -171,24 +170,23 @@ void DIALOG_CHOOSE_COMPONENT::OnTreeSelect( wxTreeListEvent& aEvent )
void DIALOG_CHOOSE_COMPONENT::OnDoubleClickTreeActivation( wxTreeListEvent& aEvent ) void DIALOG_CHOOSE_COMPONENT::OnDoubleClickTreeActivation( wxTreeListEvent& aEvent )
{ {
if( !updateSelection() ) if( updateSelection() )
return; {
// Ok, got selection. We don't just end the modal dialog here, but
// Ok, got selection. We don't just end the modal dialog here, but // wait for the MouseUp event to occur. Otherwise something (broken?)
// wait for the MouseUp event to occur. Otherwise something (broken?) // happens: the dialog will close and will deliver the 'MouseUp' event
// happens: the dialog will close and will deliver the 'MouseUp' event // to the eeschema canvas, that will immediately place the component.
// to the eeschema canvas, that will immediately place the component. //
// // NOW, here's where it gets really fun. wxTreeListCtrl eats MouseUp.
// NOW, here's where it gets really fun. wxTreeListCtrl eats MouseUp. // This isn't really feasible to bypass without a fully custom
// This isn't really feasible to bypass without a fully custom // wxDataViewCtrl implementation, and even then might not be fully
// wxDataViewCtrl implementation, and even then might not be fully // possible (docs are vague). To get around this, we use a one-shot
// possible (docs are vague). To get around this, we use a one-shot // timer to schedule the dialog close.
// timer to schedule the dialog close. //
// // See DIALOG_CHOOSE_COMPONENT::OnCloseTimer for the other end of this
// See DIALOG_CHOOSE_COMPONENT::OnCloseTimer for the other end of this // spaghetti noodle.
// spaghetti noodle. m_dbl_click_timer->StartOnce( DIALOG_CHOOSE_COMPONENT::DblClickDelay );
m_received_doubleclick_in_tree = true; }
m_dbl_click_timer->StartOnce( DIALOG_CHOOSE_COMPONENT::DblClickDelay );
} }
@ -206,12 +204,13 @@ void DIALOG_CHOOSE_COMPONENT::OnCloseTimer( wxTimerEvent& aEvent )
// purpose of this timer is defeated. // purpose of this timer is defeated.
m_dbl_click_timer->StartOnce( DIALOG_CHOOSE_COMPONENT::DblClickDelay ); m_dbl_click_timer->StartOnce( DIALOG_CHOOSE_COMPONENT::DblClickDelay );
} }
else if( m_received_doubleclick_in_tree ) else
{ {
EndModal( wxID_OK ); EndModal( wxID_OK );
} }
} }
// Test strategy to see if OnInterceptTreeEnter() works: // Test strategy to see if OnInterceptTreeEnter() works:
// - search for an item. // - search for an item.
// - click into the tree once to set focus on tree; navigate. Press 'Enter' // - click into the tree once to set focus on tree; navigate. Press 'Enter'

View File

@ -41,7 +41,6 @@ class DIALOG_CHOOSE_COMPONENT : public DIALOG_CHOOSE_COMPONENT_BASE
COMPONENT_TREE_SEARCH_CONTAINER* const m_search_container; COMPONENT_TREE_SEARCH_CONTAINER* const m_search_container;
int m_deMorganConvert; int m_deMorganConvert;
bool m_external_browser_requested; bool m_external_browser_requested;
bool m_received_doubleclick_in_tree;
public: public:
/** /**