RE: [WIN] How to ignore doubleClicks

new topic     » goto parent     » topic index » view thread      » older message » newer message

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

---------------------

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu