Tom Krenzke wrote:
> I'm writing an FLTK chess client (using 1.1.9) which lets two people connect 
> over a TCP/IP connection and play a game of chess. It work pretty well but I 
> have found one bug which I think is a result of the way FLTK is handling 
> events. I have an option that lets a play request an undo. When this option 
> is selected a modal window will pop up on the opponents screen and say 
> something like "opponent requests an undo." with a "yes" and "no" button. 
> Most of the time this works fine. The problem is if the player receiving the 
> undo request is in a menu (that is, the menu bar item is active and being 
> drawn): when the pop-up window appears the program locks up. The mouse works 
> and everything, but it seems that neither the menu nor the window (or any 
> other widget) is able to receive mouse or keyboard events. Does anyone have 
> an idea of a fix around this problem? I'd also like to understand what 
> widgets (if any) are suppose to receive events in a case like this.

It's not a bug, but you must handle this on your own. We fixed a similar 
problem 
for the common dialogs in FLTK 1.1.10 (next release).

The problem is that FLTK uses Fl::grab() while the menu is open (see below for 
a 
solution).

> One simple thing that I did think of trying is simply forcefully closing the 
> menu before the window pops up, but I can't seem to find a Fl_Widget or 
> Fl_Menu_* function that does what I want.

No, there is no such function. Maybe we'll find a way to do something like this 
in FLTK 1.3.

> Here's a small program that recreates the problem.

[most of the code removed]

Add the following three lines with "***" comments to your code, and it will 
work 
as intended.

   bool response = false;
   responseWindow->user_data((void*)&response);

   Fl_Window *g = Fl::grab();   // *** non-NULL, if menu is open
   if (g) Fl::grab(0);          // *** release menu grab()

   // Here's where it hangs
   while (responseWindow->shown())
     Fl::wait();

   if (g) Fl::grab(g);          // *** restore menu grab()


> I know I can use a call to fl_choice() to accomplish a similar task but I'd 
> prefer to have the pop up window be custom.

I don't think that this would be any better, because it would have the same 
problem.

> Also, I feel like the way I store the response in the window user_data might 
> be kind of kludgy. If you have any suggestions on a better way to do this, 
> it'd be greatly appreciated as well.

Yes, that looks like unintended usage of the user_data() method. Someone else 
may give you help on this, but this is more a question for fltk.general. And 
your primary question turns out to be one for fltk.general as well ;-)

One more note: please don't post directly to fltk.bugs. This is reserved for 
bug 
reports with the form at http://www.fltk.org/str.php - but if you are not sure 
if it's a bug, please ask in fltk.general first. Thanks.

Albrecht
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to