简体   繁体   中英

FLTK Wait for event to close window

I basically have a window with an in_box and an enter button. How can I make it so that the window stays open and drawn until the user types into the in_box and hits the enter button.

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();
}

Is there a better way to do this rather than have an enter button?

Fl::wait() is the wrong function for this. (Read the documentation for more details what that function is all about)

What you really need is to call Fl::run() at the end of that function. (I assume that is inside the main() function). I strongly suggest you read the (pretty good) FLTK 1 documentation, and get familiar with the toolkit. A good source of information are the examples inside the source tree.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM