Double+and+single+click+in+a+graphicbox

Double and single click in graphicbox
Adapted from LB NL 126: [|Double Click Demo]

> //One of the difficulties with Liberty Basic occurs in the handling of the double click event when coupled with a click event. It is easy to trap for a click event or to trap for a double click event, but if you are trapping for BOTH a click event and a double click event at the same time, LB always triggers the single click and never triggers the double click. //

> //This is because a double click event always triggers a single click event as it occurs. (...) //

code format="vbnet" 'adapted from LB NL 126 ' Determine whether the user single clicked or double clicked ' credit to Carl G for the timer idea and program code ' credit to Alyce W for the DoubleClickTime API call

'nomainwin open "click example" for graphics as #g wait
 * 1) g "when leftButtonUp [click]"
 * 2) g "when leftButtonDouble [doubleClick]"
 * 3) g "trapclose [quit]"
 * 4) g "\"

[click] 'get the user's double click time 'in Win2000 we got 500 'from calldll #user32, "GetDoubleClickTime", clickTime as ulong 'but I feel 500 is too much timer 200, [clickTimer] wait

[doubleClick] timer 0 wait
 * 1) g "\You double-clicked!"

[clickTimer] timer 0 wait
 * 1) g "\You single-clicked!"

[quit] close #g end

code