Local Links

External Links

Contact

Search this site

Fix for double click support in a multi-selection enabled Listbox


REAL Studio (REALbasic) has a time-standing bug about handling mouse clicks into a Listbox wrong: Whenever it receives a mouse click, it immediately, after invoking the CellClick event, selects the targeted row.

While this is not an issue with list boxes that only allow single selections, this leads to problems when multiple row selections are enabled for the Listbox: A right-click (to open a contextual menu) as well as a double click will deselect all other rows, losing the user's multi-selection without intent.

For right clicks, this can be dealt with easily: Instead of relying on RB's dedicated events for contextual menus, one can check for the contextual click right inside the CellClick event handler and open the context menu directly, then returning true from the event, which prevents RB's framework from changing the selection.

For double clicks, however, this is more complicated. After a first unsuccessful attempt, I eventually found a work-around that seems to keep all other functionality intact, such as dragging and other special click actions (with shift, control etc.). The trick is to undo the clearing of the selection right in the event that's called after CellClick.

I've thus written a Listbox subclass which takes care of this procedure automagically. To fix this problem in your own code, add the MultiSelectionListBox and DelegatingTimer classes to your project and change the super property of your ListBox controls to MultiSelectionListBox.

Download

Download the project with the needed classes and demonstration code here: http://files.tempel.org/RB/ListBox_Multiple_Selection_Fix.rbp.zip

See also

The latest bug report on this issue: case 14395


Page last modified on 2012-10-23, 15:19 EDT
Powered by PmWiki