Older Version
Newer Version
StPendl
Jul 17, 2010
- "added resetting of selection to be able to select the same item more than once in a row"
==How to have a single- and a double-click handler for a listbox== [[user:StPendl|1189413695]] Most people do not know, that a listbox can respond to a single-click by setting the **singleClickSelect** property. You can have a different event handler for single-clicks by adding a branch label (**singleClickSelect [action]**) too. The problem we have, when using both event handlers, is to know which one to use, because Windows sends the single-click and double-click messages to the control, when double-clicking a listbox item. Here is a demo for using both event handlers based on the [[http://babek.info/libertybasicfiles/lbnews/nl126/doubleclick.htm|Double Click Demo in Newsletter 126]] [[code format="vbnet"]] nomainwin for i = 1 to 10 array$(i) = str$(i) next listbox #m.lb, array$(, [DoubleClickAction], 10, 10, 200, 200 statictext #m.txt, "Select an item or double click it.", 10, 220, 200,2040 open "test listbox event handlers" for window as #m #m "trapclose [quit]" #m.lb "singleClickSelect [SingleClickAction]" wait [SingleClickAction] calldll #user32, "GetDoubleClickTime", delay as ulong timer delay, [continue] wait [continue] timer 0 #m.txt "Single ClickAction - Double-Click-Delay:Action"; chr$(13); "Double-Click-Delay: "; delay; "ms" ' reset selection #m.lb "selectindex 0" wait [DoubleClickAction] timer 0 #m.txt "Double Click Action" ' reset selection #m.lb "selectindex 0" wait [quit] close #m end [[code]]