Don't send event from wxMSW::wxListCtrl::DeleteAllItems() if it did nothing.
wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS should only be sent if the control hadn't been empty before. Document this behaviour and adjust wxMSW to match the other platforms. Also document the return value better. Closes #12336. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65381 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -214,9 +214,15 @@ public:
|
||||
/**
|
||||
Deletes all items in the list control.
|
||||
|
||||
@note This function does @e not send the @c wxEVT_COMMAND_LIST_DELETE_ITEM
|
||||
event because deleting many items from the control would be too slow
|
||||
then (unlike wxListCtrl::DeleteItem).
|
||||
This function does @e not send the @c wxEVT_COMMAND_LIST_DELETE_ITEM
|
||||
event because deleting many items from the control would be too slow
|
||||
then (unlike wxListCtrl::DeleteItem) but it does send the special @c
|
||||
wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS event if the control was not empty.
|
||||
If it was already empty, nothing is done and no event is sent.
|
||||
|
||||
@return @true if the items were successfully deleted or if the control
|
||||
was already empty, @false if an error occurred while deleting the
|
||||
items.
|
||||
*/
|
||||
bool DeleteAllItems();
|
||||
|
||||
|
@@ -1464,7 +1464,9 @@ bool wxListCtrl::DeleteItem(long item)
|
||||
// Deletes all items
|
||||
bool wxListCtrl::DeleteAllItems()
|
||||
{
|
||||
return ListView_DeleteAllItems(GetHwnd()) != 0;
|
||||
// Calling ListView_DeleteAllItems() will always generate an event but we
|
||||
// shouldn't do it if the control is empty
|
||||
return !GetItemCount() || ListView_DeleteAllItems(GetHwnd()) != 0;
|
||||
}
|
||||
|
||||
// Deletes all items
|
||||
|
Reference in New Issue
Block a user