Don't send events for non-item

This commit is contained in:
Kvaz1r
2021-07-13 11:37:46 +03:00
parent c345205396
commit 0a241d2dfc
2 changed files with 10 additions and 16 deletions

View File

@@ -142,9 +142,8 @@ public:
// select the item which is diff items below the current one // select the item which is diff items below the current one
void ChangeCurrent(int diff); void ChangeCurrent(int diff);
// activate (i.e. send a LISTBOX_DOUBLECLICKED message) the specified or // activate (i.e. send a LISTBOX_DOUBLECLICKED message) the specified item
// current (if -1) item void Activate(int item);
void Activate(int item = -1);
// select or unselect the specified or current (if -1) item // select or unselect the specified or current (if -1) item
void DoSelect(int item = -1, bool sel = true); void DoSelect(int item = -1, bool sel = true);

View File

@@ -1078,27 +1078,22 @@ void wxListBox::DoSelect(int item, bool sel)
void wxListBox::SelectAndNotify(int item) void wxListBox::SelectAndNotify(int item)
{ {
DoSelect(item); if( item != -1 )
{
SendEvent(wxEVT_LISTBOX); DoSelect(item);
SendEvent(wxEVT_LISTBOX);
}
} }
void wxListBox::Activate(int item) void wxListBox::Activate(int item)
{ {
if ( item != -1 ) if ( item != -1 )
{
SetCurrentItem(item); SetCurrentItem(item);
else if ( !(GetWindowStyle() & wxLB_MULTIPLE) )
item = m_current; DeselectAll(item);
if ( !(GetWindowStyle() & wxLB_MULTIPLE) )
{
DeselectAll(item);
}
if ( item != -1 )
{
DoSelect(item); DoSelect(item);
SendEvent(wxEVT_LISTBOX_DCLICK); SendEvent(wxEVT_LISTBOX_DCLICK);
} }
} }