C++ fltk:我有一个带有in_box和out_box的窗口,我怎样才能让用户在in_box中输入回车,然后继续事件的其余部分。现在,窗口只是显示出来,然后消失。
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();发布于 2011-11-23 04:08:24
我不确定这是否能解决您的问题,但要保持窗口打开,请返回Fl::run()。
发布于 2011-11-24 04:17:53
我以前从未见过In_box和Out_box,所以我假设它们是您自己的类或结构……
因此,这里的代码应该类似于(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
}https://stackoverflow.com/questions/8231577
复制相似问题