> As we know, the button widget has a callback, by default it 
> will excute this callback afte we push and release the 
> button. But how to add another callback to the button widget. 
> So I can excute callback A when push the button, and excute 
> 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 
header_name {.h} 
code_name {.cxx}
decl {\#include <stdio.h>} {} 

Function {} {open
} {
  Fl_Window main_win {open
    xywh {494 312 376 278} type Double visible
  } {
    Fl_Button bt_1 {
      label button
      callback {int ev = Fl::event();

if(ev == FL_PUSH) puts("down");

if(ev == 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}
    }
  }
} 
------------------------

SELEX Galileo Ltd
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