1. [Win32Lib] button "stobe"?

Is there some way to get a button to "strobe" on being clicked?  I mean such
that if a user clicks on a button & holds it down, a recurring event can be
discerned by the program & responded to, like when you click on a scroll
button.  I tried onClick & onMouse( for event LEFT_DOWN ), but neither
worked for me.

Dan Moyer

new topic     » topic index » view message » categorize

2. Re: [Win32Lib] button "stobe"?

Derek,

Ok, the timer is something I had just tried before I checked here, & did
discover that it wouldn't run from a button press, & then I saw some places
in Win32Lib that seemed to exclude onMouse from buttons (anything but
windows?), so I  see what you're saying.  My only question is, would the
change you indicated be included in the next version of Win32Lib, so my code
could work for anyone ?

Dan

----- Original Message -----
From: "Derek Parnell" <Derek.Parnell at SYD.RABOBANK.COM>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, July 10, 2002 2:15 AM
Subject: RE: [Win32Lib] button "stobe"?


>
> Dan,
> this is doable. But you need a minor change to the library first.
>
> In the routine fDoMouse(), find the line ...
>
>     doActions = (and_bits(classAttr[window_type[id]], w32Clickable) != 0)
>
> And add after it ...
>
>                  or (window_family[id] = BUTTON)
>
> Now you can set up a timer and start it running when you got a LEFT_DOWN
> event and stop it when the corresponding LEFT_UP event occurs. Then each
> 'click' of the timer is your "strobe" event.
>
> Something like this...
>
> ---------
> include win32lib.ew
> without warning
> constant MainWin = create(Window, "Repeating Button", 0, 0, 0, 200, 140,
0),
>          SB = create(StatusBar, "", MainWin, 0, 0, 0, 0, 0),
>          Btn = create(Button, "Push Me", MainWin, 10, 40, 64, 25, 0)
>
> constant Strobe = 1
>
> integer cntr cntr = 0
> integer inc
> procedure Mouse_Btn(integer self, integer event, sequence parms)
>       if parms[1] = WM_LBUTTONDOWN then
>            cntr = 0
>            setTimer(MainWin, Strobe, 100) -- 10 flashes/sec
>            setText(SB, "")
>       elsif parms[1] = WM_LBUTTONUP then
>            killTimer(MainWin, Strobe)
>            setText(Btn, "Push Me")
>            setText(SB, sprintf("The result was %d", cntr))
>       end if
> end procedure
>
> procedure StrobeFlash(integer self, integer event, sequence parms)
>     -- do whatever you have to --
>     cntr += 1
>     setText(Btn, sprintf("%d", cntr))
> end procedure
>
> setHandler( MainWin, w32HTimer, routine_id("StrobeFlash"))
> setHandler( Btn,     w32HMouse, routine_id("Mouse_Btn"))
>
> WinMain(MainWin, 0)
> ---------
> Derek.
>
> > -----Original Message-----
> > From: Dan Moyer [mailto:DANIELMOYER at prodigy.net]
> > Sent: Wednesday, 10 July 2002 13:38
> > To: EUforum
> > Subject: [Win32Lib] button "stobe"?
> >
> >
> > Is there some way to get a button to "strobe" on being
> > clicked?  I mean such
> > that if a user clicks on a button & holds it down, a
> > recurring event can be
> > discerned by the program & responded to, like when you click
> > on a scroll
> > button.  I tried onClick & onMouse( for event LEFT_DOWN ), but neither
> > worked for me.
> >
> > Dan Moyer
> >
> >
> ==================================================================
>
>
> ==================================================================
>
>
>
>

new topic     » goto parent     » topic index » view message » categorize

3. Re: [Win32Lib] button "stobe"?

Thanks!  I applied your suggestion, & not only did your demo work neat, but
the code I had previously written trying to make timers do the strobing
actually worked too.

Dan

----- Original Message -----
From: "Derek Parnell" <Derek.Parnell at SYD.RABOBANK.COM>
To: "EUforum" <EUforum at topica.com>
Subject: RE: [Win32Lib] button "stobe"?


>
> Dan,
> this is doable. But you need a minor change to the library first.
>
> In the routine fDoMouse(), find the line ...
>
>     doActions = (and_bits(classAttr[window_type[id]], w32Clickable) != 0)
>
> And add after it ...
>
>                  or (window_family[id] = BUTTON)
>
> Now you can set up a timer and start it running when you got a LEFT_DOWN
> event and stop it when the corresponding LEFT_UP event occurs. Then each
> 'click' of the timer is your "strobe" event.
>
> Something like this...
>
> ---------
> include win32lib.ew
> without warning
> constant MainWin = create(Window, "Repeating Button", 0, 0, 0, 200, 140,
0),
>          SB = create(StatusBar, "", MainWin, 0, 0, 0, 0, 0),
>          Btn = create(Button, "Push Me", MainWin, 10, 40, 64, 25, 0)
>
> constant Strobe = 1
>
> integer cntr cntr = 0
> integer inc
> procedure Mouse_Btn(integer self, integer event, sequence parms)
>       if parms[1] = WM_LBUTTONDOWN then
>            cntr = 0
>            setTimer(MainWin, Strobe, 100) -- 10 flashes/sec
>            setText(SB, "")
>       elsif parms[1] = WM_LBUTTONUP then
>            killTimer(MainWin, Strobe)
>            setText(Btn, "Push Me")
>            setText(SB, sprintf("The result was %d", cntr))
>       end if
> end procedure
>
> procedure StrobeFlash(integer self, integer event, sequence parms)
>     -- do whatever you have to --
>     cntr += 1
>     setText(Btn, sprintf("%d", cntr))
> end procedure
>
> setHandler( MainWin, w32HTimer, routine_id("StrobeFlash"))
> setHandler( Btn,     w32HMouse, routine_id("Mouse_Btn"))
>
> WinMain(MainWin, 0)
> ---------
> Derek.
>
> > -----Original Message-----
> > From: Dan Moyer [mailto:DANIELMOYER at prodigy.net]
> > Sent: Wednesday, 10 July 2002 13:38
> > To: EUforum
> > Subject: [Win32Lib] button "stobe"?
> >
> >
> > Is there some way to get a button to "strobe" on being
> > clicked?  I mean such
> > that if a user clicks on a button & holds it down, a
> > recurring event can be
> > discerned by the program & responded to, like when you click
> > on a scroll
> > button.  I tried onClick & onMouse( for event LEFT_DOWN ), but neither
> > worked for me.
> >
> > Dan Moyer
> >
> >
> ==================================================================
>
>
> ==================================================================
>
>
>
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu