Search Pane: add Activation (enter/double click) event support
(cherry picked from commit d915cb780e
)
This commit is contained in:
parent
a3197578d6
commit
13fb23d59d
|
@ -33,6 +33,7 @@ SEARCH_PANE_LISTVIEW::SEARCH_PANE_LISTVIEW( SEARCH_HANDLER* handler, wxWindow* p
|
|||
RefreshColumnNames();
|
||||
|
||||
Bind( wxEVT_LIST_ITEM_SELECTED, &SEARCH_PANE_LISTVIEW::OnItemSelected, this );
|
||||
Bind( wxEVT_LIST_ITEM_ACTIVATED, &SEARCH_PANE_LISTVIEW::OnItemActivated, this );
|
||||
Bind( wxEVT_LIST_ITEM_FOCUSED, &SEARCH_PANE_LISTVIEW::OnItemSelected, this );
|
||||
Bind( wxEVT_LIST_ITEM_DESELECTED, &SEARCH_PANE_LISTVIEW::OnItemDeselected, this );
|
||||
}
|
||||
|
@ -41,6 +42,7 @@ SEARCH_PANE_LISTVIEW::SEARCH_PANE_LISTVIEW( SEARCH_HANDLER* handler, wxWindow* p
|
|||
SEARCH_PANE_LISTVIEW::~SEARCH_PANE_LISTVIEW()
|
||||
{
|
||||
Unbind( wxEVT_LIST_ITEM_SELECTED, &SEARCH_PANE_LISTVIEW::OnItemSelected, this );
|
||||
Unbind( wxEVT_LIST_ITEM_ACTIVATED, &SEARCH_PANE_LISTVIEW::OnItemActivated, this );
|
||||
Unbind( wxEVT_LIST_ITEM_FOCUSED, &SEARCH_PANE_LISTVIEW::OnItemSelected, this );
|
||||
Unbind( wxEVT_LIST_ITEM_DESELECTED, &SEARCH_PANE_LISTVIEW::OnItemDeselected, this );
|
||||
}
|
||||
|
@ -65,6 +67,23 @@ void SEARCH_PANE_LISTVIEW::GetSelectRowsList( std::vector<long>& aSelectedList )
|
|||
}
|
||||
|
||||
|
||||
void SEARCH_PANE_LISTVIEW::OnItemActivated( wxListEvent& aEvent )
|
||||
{
|
||||
CallAfter(
|
||||
[&]()
|
||||
{
|
||||
m_handler->ActivateItem( aEvent.GetIndex() );
|
||||
|
||||
// Reset our selection to match the selected list items
|
||||
std::vector<long> list;
|
||||
GetSelectRowsList( list );
|
||||
m_handler->SelectItems( list );
|
||||
} );
|
||||
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
||||
|
||||
void SEARCH_PANE_LISTVIEW::OnItemSelected( wxListEvent& aEvent )
|
||||
{
|
||||
CallAfter(
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
virtual wxString GetResultCell( int row, int col ) = 0;
|
||||
|
||||
virtual void SelectItems( std::vector<long>& aItemRows ) {}
|
||||
virtual void ActivateItem( long aItemRow ) {}
|
||||
|
||||
protected:
|
||||
wxString m_name;
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
protected:
|
||||
wxString OnGetItemText( long item, long column ) const override;
|
||||
void OnItemSelected( wxListEvent& aEvent );
|
||||
void OnItemActivated( wxListEvent& aEvent );
|
||||
void OnItemDeselected( wxListEvent& aEvent );
|
||||
|
||||
void GetSelectRowsList( std::vector<long>& aSelectedList );
|
||||
|
|
Loading…
Reference in New Issue