FLTK等待事件关闭窗口

时间:2011-11-22 10:19:52

标签: c++ user-interface fltk

我基本上有一个带有in_box和enter按钮的窗口。我怎样才能使窗口保持打开和绘制,直到用户输入in_box并点击回车按钮。

Window w(Point(100,100),200,200, "Category Sales");
Button enter(Point(25,25),110,25,"Enter",enter);
In_box cat_in(Point(75,75),100,20,"Category:");
w.attach(cat_in);
w.attach(enter);
Fl::wait();
if(ent==true)
{
category = cat_in.get_string();
reference_to<My_button>(addr).receiver->do_categories();
}

有没有比这更好的方法而不是输入按钮?

1 个答案:

答案 0 :(得分:1)

Fl :: wait()是错误的功能。 (阅读文档以获取有关该功能的更多详细信息)

你真正需要的是在该函数的末尾调用Fl :: run()。 (我假设它在main()函数内)。我强烈建议你阅读(相当不错的)FLTK 1文档,并熟悉该工具包。源代码树中的示例是一个很好的信息来源。