2011-11-22 72 views
0

C++ fltk:我有一个带有in_box和out_box的窗口,我该如何让它可以让用户输入in_box命中,然后继续处理其余的事件。现在窗户刚刚出现并消失。Fltk窗口等待

Window w(Point(100,100),200,200, "Category Sales"); 
In_box cat_in(Point(75,75),100,20,"Category:"); 
Out_box cat_out(Point(75,115),100,20,"Sales:"); 
w.attach(cat_in); 
w.attach(enter); 
category = cat_in.get_string(); 

回答

0

我不确定这是否能解决您的问题,但保持窗口打开,返回Fl :: run()。

1

我以前从来没有见过In_box和Out_box,所以我会假设这些是你自己的类或结构......如前所述 - 启动FLTK事件循环的最简单方法是使用Fl :: run()或(FLTK2)fltk :: run()。

所以,在这里你的代码应该是这个样子(FLTK2):

#include <fltk/Window.h> 
#include <fltk/Widget.h> 
#include <fltk/run.h> 

using namespace fltk; 

int main(int argc, char **argv) { 

    // your code begins 
    Window w(Point(100,100),200,200, "Category Sales"); 
    In_box cat_in(Point(75,75),100,20,"Category:"); 
    Out_box cat_out(Point(75,115),100,20,"Sales:"); 
    w.attach(cat_in); 
    w.attach(enter); 
    category = cat_in.get_string(); 
    // your code ends 

    w->end(); 
    w->show(argc, argv); 
    return run(); // this line is the most important, here we start the FLTK event-loop 
}