don't generate EVT_LISTBOX_DCLICK events with incorrect indices [backport of r58405 from trunk] (closes #10429)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@58754 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -154,6 +154,7 @@ wxMSW:
|
|||||||
- Fixed invisible CHM tooltip text bug when window text colour is black.
|
- Fixed invisible CHM tooltip text bug when window text colour is black.
|
||||||
- Automatically adjust toolbar's tool size if the provided bitmaps
|
- Automatically adjust toolbar's tool size if the provided bitmaps
|
||||||
don't fit into the default size.
|
don't fit into the default size.
|
||||||
|
- Don't generate EVT_LISTBOX_DCLICK events with incorrect indices.
|
||||||
|
|
||||||
|
|
||||||
wxMSW/CE:
|
wxMSW/CE:
|
||||||
|
@@ -545,11 +545,11 @@ wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
|
|||||||
int wxListBox::DoListHitTest(const wxPoint& point) const
|
int wxListBox::DoListHitTest(const wxPoint& point) const
|
||||||
{
|
{
|
||||||
LRESULT lRes = ::SendMessage(GetHwnd(), LB_ITEMFROMPOINT,
|
LRESULT lRes = ::SendMessage(GetHwnd(), LB_ITEMFROMPOINT,
|
||||||
0L, MAKELONG(point.x, point.y));
|
0, MAKELPARAM(point.x, point.y));
|
||||||
|
|
||||||
// non zero high-order word means that this item is outside of the client
|
// non zero high-order word means that this item is outside of the client
|
||||||
// area, IOW the point is outside of the listbox
|
// area, IOW the point is outside of the listbox
|
||||||
return HIWORD(lRes) ? wxNOT_FOUND : lRes;
|
return HIWORD(lRes) ? wxNOT_FOUND : LOWORD(lRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxListBox::SetString(unsigned int n, const wxString& s)
|
void wxListBox::SetString(unsigned int n, const wxString& s)
|
||||||
@@ -702,13 +702,18 @@ wxSize wxListBox::DoGetBestSize() const
|
|||||||
bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
|
bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
|
||||||
{
|
{
|
||||||
wxEventType evtType;
|
wxEventType evtType;
|
||||||
|
int n;
|
||||||
if ( param == LBN_SELCHANGE )
|
if ( param == LBN_SELCHANGE )
|
||||||
{
|
{
|
||||||
evtType = wxEVT_COMMAND_LISTBOX_SELECTED;
|
evtType = wxEVT_COMMAND_LISTBOX_SELECTED;
|
||||||
|
n = SendMessage(GetHwnd(), LB_GETCARETINDEX, 0, 0);
|
||||||
|
|
||||||
|
// NB: conveniently enough, LB_ERR is the same as wxNOT_FOUND
|
||||||
}
|
}
|
||||||
else if ( param == LBN_DBLCLK )
|
else if ( param == LBN_DBLCLK )
|
||||||
{
|
{
|
||||||
evtType = wxEVT_COMMAND_LISTBOX_DOUBLECLICKED;
|
evtType = wxEVT_COMMAND_LISTBOX_DOUBLECLICKED;
|
||||||
|
n = HitTest(ScreenToClient(wxGetMousePosition()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -716,23 +721,21 @@ bool wxListBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id))
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCommandEvent event(evtType, m_windowId);
|
|
||||||
event.SetEventObject( this );
|
|
||||||
|
|
||||||
// retrieve the affected item
|
// retrieve the affected item
|
||||||
int n = SendMessage(GetHwnd(), LB_GETCARETINDEX, 0, 0);
|
if ( n == wxNOT_FOUND )
|
||||||
if ( n != LB_ERR )
|
return false;
|
||||||
{
|
|
||||||
|
wxCommandEvent event(evtType, m_windowId);
|
||||||
|
event.SetEventObject(this);
|
||||||
|
|
||||||
if ( HasClientObjectData() )
|
if ( HasClientObjectData() )
|
||||||
event.SetClientObject( GetClientObject(n) );
|
event.SetClientObject( GetClientObject(n) );
|
||||||
else if ( HasClientUntypedData() )
|
else if ( HasClientUntypedData() )
|
||||||
event.SetClientData( GetClientData(n) );
|
event.SetClientData( GetClientData(n) );
|
||||||
|
|
||||||
event.SetString(GetString(n));
|
event.SetString(GetString(n));
|
||||||
event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : true );
|
|
||||||
}
|
|
||||||
|
|
||||||
event.SetInt(n);
|
event.SetInt(n);
|
||||||
|
event.SetExtraLong( HasMultipleSelection() ? IsSelected(n) : true );
|
||||||
|
|
||||||
return GetEventHandler()->ProcessEvent(event);
|
return GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user