1. RE: [WIN] How to ignore doubleClicks
- Posted by joshua goldberg <futures8 at bellsouth.net> May 14, 2001
- 356 views
Hi Derek, Thanks for the help. I think that your first glance was correct. I 'lifted' the 'event' test right out of the program 'RUNTHIS.EXW', without noticing that it was part of the onMouse handler, and I had not referenced that routine in the program. So, of course, 'event' was not assigned a value. The button control in question is, in fact, a PushButton control. I need to go back to my program and see how and where to call the onMouse handler, to make use of the 'event = LeftDoubleClick". 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? I'd like to keep trying to figure this out (with your kind help) before giving up and sending you the program; I'd prefer not to impose too much on your valuable time. ---------------------------- ORIGINAL MESSAGE ------------------------------ Hi Josh, at first glace, I'd say there is a problem with your code then. The "event" parameter is sent to the onMouse handler and definitely has a value. But just to make sure, does the Euphoria error refer to a line in win32lib code or your code? There is a known bug with double-clicks being ignored on Window controls, but you mention that you're using buttons. Is that a PushButton control then? To fix the ignored double-clicks you need to change the win32lib.ew file. Replace the line that has ... vWindowClassStyle = {CS_HREDRAW, CS_VREDRAW} with ... vWindowClassStyle = {CS_HREDRAW, CS_VREDRAW, CS_DBLCLKS } but i don't think that's your problem, in this case. For other controls, Windows sends the mouse events in this order ... onMouse(WM_LBUTTONDOWN) onMouse(WM_LBUTTONUP) onClick() onMouse(WM_LBUTTONDBLCLK) onMouse(WM_LBUTTONUP) and there maybe some onMouse(WM_MOUSEMOVE) in amongst those. Finally, you can always send me the code (or a reproducable sample of the problem) to examine. ------ Derek Parnell Melbourne, Australia "To finish a job quickly, go slower." ----- Original Message ----- From: "Jim Duffy" <futu- at earthlink.net>; To: "EUforum" <EUfo- at topica.com>; Sent: Tuesday, May 15, 2001 5:01 AM Subject: [WIN] How to ignore doubleClicks I'm having trouble with a program which has several button controls (Win32lib.ew). If a user clicks on a button, the expected processes execute correctly. But, if the user double-clicks on a button, the program code executes twice. I need a way to have the program treat a 'double-click' as if it were a 'single left-click'. I've searched through the programs which came with Win32Lib (v.55.1) and found 'if event = LeftDoubleClick' in program 'RUNTHIS.EXW', but haven't been able to get this working in the program I'm working on (get error "event" has not been assigned a value." Derek Parnell wrote: > Hi Josh, > at first glace, I'd say there is a problem with your code then. The > "event" parameter is sent to the onMouse handler and definitely has a > value. > But just to make sure, does the Euphoria error refer to a line in > win32lib > code or your code? > > There is a known bug with double-clicks being ignored on Window > controls, > but you mention that you're using buttons. Is that a PushButton control > then? > > To fix the ignored double-clicks you need to change the win32lib.ew > file. > Replace the line that has ... > > vWindowClassStyle = {CS_HREDRAW, CS_VREDRAW} > > with ... > > vWindowClassStyle = {CS_HREDRAW, CS_VREDRAW, CS_DBLCLKS } > > but i don't think that's your problem, in this case. > > For other controls, Windows sends the mouse events in this order ... > > onMouse(WM_LBUTTONDOWN) > onMouse(WM_LBUTTONUP) > onClick() > onMouse(WM_LBUTTONDBLCLK) > onMouse(WM_LBUTTONUP) > > and there maybe some onMouse(WM_MOUSEMOVE) in amongst those. > > Finally, you can always send me the code (or a reproducable sample of > the > problem) to examine. > ------ > Derek Parnell > Melbourne, Australia > "To finish a job quickly, go slower." > > ----- Original Message ----- > From: "Jim Duffy" <futures8 at earthlink.net> > To: "EUforum" <EUforum at topica.com> > Sent: Tuesday, May 15, 2001 5:01 AM > Subject: [WIN] How to ignore doubleClicks > > <snip> josh
2. RE: [WIN] How to ignore doubleClicks
- Posted by Derek Parnell <ddparnell at bigpond.com> May 14, 2001
- 352 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 ---------------------