RE: [WIN] How to ignore doubleClicks
- Posted by Derek Parnell <ddparnell at bigpond.com> May 14, 2001
- 351 views
Hi Josh, > But then, I'm still not clear on how to have the > program treat a doubleclick the same way as a > single click. I guess something like > > if event = LeftDoubleClick then > --- do the same thing as for a single onClick > else > --- do the single click code here, too. > end if > > which looks a bit silly on the surface, but how else to deal with an > accidental double click? Here's what I'd do (somebody else might do it differently of course). ---------- Sample Code ---------- without warning include win32lib.ew integer win, sb, btn, counter win = create(Window, "TEST", 0, 0 ,0, 300, 300, 0) sb = create(StatusBar, "", win, 0, 0, 0, 0, 0) btn = create(PushButton, "push me", win, 10, 10, 100, 25, 0) counter = 0 atom chek, maxt -- Initialize maxt = (w32Func(xGetDoubleClickTime,{}) / 1000) chek = maxt procedure ClickHandler() -- See if enough time has slipped by yet before I can register a click. if time() - chek >= maxt then -- do click code now. counter+=1 setText(sb, sprintf("Click %d", counter)) end if -- restart the timer chek = time() end procedure onClick[btn] = routine_id("ClickHandler") WinMain(win, 0) ----------- cheers, Derek Parnell Senior Design Engineer Global Technology Australasia Ltd dparnell at glotec.com.au ---------------------