> I have a push button.  When I press it I want an event to 
> happen for as long as it is pressed, and if I let go of the 
> button the event shold stop.
> 
> The eay is set up right now is:  If  I press once the event 
> happens and I need to send a separate command to make that event stop.
> 
> any ideas

Is your program a single thread, or is it multiple threads? That could
make a big difference in how best to handle this.

If your program is a single thread, and you want to be actively holding
the button down, maybe an Fl_Repeat_Button would be worth a look? That
will repeatedly trigger the button's callback as long as you hold the
button down. Will that do what you want?

A variant of that approach is to have your button's callback start a
timer (with Fl::add_timeout) or possibly even an idle task (with
Fl::add_idle) that will perform your actions. Then cancel the timer/idle
when the button is released, of course...

If you have a thread for your GUI, and another thread that is performing
the task in question, it can be as simple as having the button's
callback set/clear a flag depending on whether it is pressed or not, and
the worker thread just polls that flag each time it runs through it's
steps.

Any good?
-- 
Ian





SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to