> char Fl_Button::value() const
> Yet in this code, it appears to return NULL. Am I doing something
> wrong?
It returns a char with value 0, not a NULL, but the iostream treats that
as an empty string, I think - if you cast it to an int, it will likley
work (in that it will always print a zero.)
In the callback, as you have coded it, the button value will always be
zero, since the callback happens when (i.e. just after) the button is
released.
If you want to see it toggle between 0,1, then you need to set the
button type to a toggle type. If you want the callback to fire when the
button is pressed instead of (or as well as) when it is released, you
will need to read the docs on the FL_WHEN_* conditions and assign the
behaviour you want to your button...
// button_value.cpp
#include <iostream>
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Button.H>
using namespace std;
Fl_Double_Window *win;
Fl_Button *but;
void but_cb(void)
{
int x = but->value();
cout << x << endl;
}
int main()
{
win = new Fl_Double_Window(100, 100);
but = new Fl_Button(20, 40, 60, 20, "HIT ME");
but->labelsize(9);
but->callback((Fl_Callback*)but_cb);
win->show();
return(Fl::run());
}
// end of button_value.cpp
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