>
> > As we know, the button widget has a callback, by default it=20
> > will excute this callback afte we push and release the=20
> > button. But how to add another callback to the button widget.=20
> > So I can excute callback A when push the button, and excute=20
> > callback B when release the button. Thanks.
>
> As Edzard says, it is pretty easy to check the event type in the
> callback. Below is a (fltk-1) fluid file that illustrates a minimal
> example of doing that, should show you how to proceed. Fltk-2 is the
> same, but I don't use it...
>
> > My fltk version is v2.0
>
> Yup - as I have said before; Good luck with that!
>
>
> Anyway, here's the example. Simple, but works OK.
>
> ------------------------
> # data file for the Fltk User Interface Designer (fluid)
> version 1.0110=20
> header_name {.h}=20
> code_name {.cxx}
> decl {\#include <stdio.h>} {}=20
>
> Function {} {open
> } {
> Fl_Window main_win {open
> xywh {494 312 376 278} type Double visible
> } {
> Fl_Button bt_1 {
> label button
> callback {int ev =3D Fl::event();
>
> if(ev =3D=3D FL_PUSH) puts("down");
>
> if(ev =3D=3D FL_RELEASE) puts("up");
>
> fflush(stdout);} selected
> xywh {25 25 80 40} when 1
> }
> Fl_Button quit_bt {
> label Quit
> callback {main_win->hide();}
> xywh {265 210 75 35}
> }
> }
> }=20
> ------------------------
>
> SELEX Galileo Ltd
> Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS=
> 14 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.
> ********************************************************************
>
Dear Ian & Edzard,
Many thanks for your suggestion. But the default callback of the button widget
will be called after the release event. So the push event will not call the
callback. How to change to make the push and release event can both call the
callback function? Thanks.
Best regards,
Leo
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk