Here's what I *think* you meant.
This appears to work just fine (though I suspect I would have approached
this differently, this seems to be doing what you intended...!)
/*********************************************************
fltk-config --compile test.cxx
*********************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Int_Input.H>
class SetupTest : public Fl_Window
{
public:
Fl_Button *Reset;
Fl_Int_Input *inputA;
Fl_Int_Input *inputB;
bool state;
int valCount;
void InputCb_i(Fl_Widget* wgt, void* v);
static void InputCb(Fl_Widget* wgt, void* v);
void Reset_CB_i(Fl_Widget* wgt, void* v);
static void Reset_CB(Fl_Widget* wgt, void* v);
void reset_fn();
SetupTest(int X, int Y, int W, int H);
};
SetupTest::SetupTest(int X, int Y, int W, int H) : Fl_Window(X, Y, W, H)
{
this->begin();
Reset = new Fl_Button(226, 20, 64, 20, "Reset");
inputA = new Fl_Int_Input(215, 50, 20, 24, "InputA");
inputA->tooltip("enter number A");
inputA->type(2);
inputA->when(FL_WHEN_RELEASE);
inputB = new Fl_Int_Input(215, 80, 20, 24, "InputB");
inputB->tooltip("enter number B");
inputB->type(2);
inputB->when(FL_WHEN_RELEASE);
this->end();
valCount = 0;
state = false;
inputA->callback((Fl_Callback*) InputCb);
inputB->callback((Fl_Callback*) InputCb);
Reset->callback((Fl_Callback*) Reset_CB);
show ();
}
void SetupTest::InputCb_i(Fl_Widget* w, void* v)
{
Fl_Int_Input* inp = (Fl_Int_Input*) w;
char* p;
long int longI = 0;
if (inp->changed())
{
inp->clear_changed();
longI = strtol(inp->value(), &p, 10);
printf("%s '%s'\n", inp->label(), inp->value());
printf("%ld\n", longI); fflush(stdout);
inp->deactivate();
valCount++;
}
if(valCount > 1)
{
printf("READY : %d\n", valCount); fflush(stdout);
valCount = 0;
state = true;
}
}
void SetupTest::InputCb(Fl_Widget* wgt, void* v)
{
SetupTest *st = (SetupTest*)wgt->parent();
st->InputCb_i(wgt, v);
}
void SetupTest::Reset_CB_i(Fl_Widget* w, void* v)
{
Fl_Button* button = (Fl_Button*)w;
if(state)
{
reset_fn();
state = false;
}
}
void SetupTest::Reset_CB(Fl_Widget* wgt, void* v)
{
SetupTest *st = (SetupTest*)wgt->parent();
st->Reset_CB_i(wgt, v);
}
void SetupTest::reset_fn()
{
inputB->activate();
inputA->activate();
}
int main (int argc, char ** argv)
{
SetupTest testObj(100, 100, 300, 200);
return Fl::run();
}
/* End of file */
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