I'd like to start Tcl_Main from within an fltk application. But once started in 
inputcb (see blow) it takes over the control. Is there a way to add tcl to the 
fltk event loop?

Regards,
Jens


#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input.H>
#include <iostream>
#include <sstream>
#include <string>
#include <tcl.h>

using namespace std;

int argcc;
char **argvv;

int AppInit(Tcl_Interp *interp) {
        if(Tcl_Init(interp) == TCL_ERROR) return TCL_ERROR;
        Tcl_SetVar(interp,"tcl_rcFileName","~/.wishrc",TCL_GLOBAL_ONLY);
        return TCL_OK;
}

Fl_Input *input;

static void inputcb(Fl_Widget *w, void *userdata) {
  Fl_Input *inpt = (Fl_Input*)w;
  cout << "entry: " << inpt->value() << endl;
  Tcl_Main(argcc, argvv, AppInit);
}

void stdincb(int , void*) {
  int i = 0;
  cout << "Please enter an integer value: ";
  cin >> i;
  cout << "Out: " << i << endl;
  stringstream ss;
  ss << i;
  input->value(ss.str().c_str());
}

int main(int argc, char *argv[]) {
  argvv = argv;
  argcc = argc;
    Fl_Window win( 300,200,"Window" );
    input = new Fl_Input(160, 40, 100, 30, "Enter text:");
    input->callback(inputcb);
    Fl::add_fd(0,FL_READ,stdincb);
    win.begin();
    win.end();
    win.show();
    return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to