caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* What the Graphics module is missing
@ 2005-01-26  9:17 Andrej Bauer
  0 siblings, 0 replies; only message in thread
From: Andrej Bauer @ 2005-01-26  9:17 UTC (permalink / raw)
  To: caml-list

I recently wrote a simple single-window application in ocaml.
For artistic purposes I wanted it to give it a "raw" look (think VT100),
so I did want to use an existing library. The Graphics module seemed
like a good solution. However, I think the Graphics module is
missing a function that empties the event queue.

Suppose my program is doing something and while it is doing it, it
periodically polls for user interface events (think "cooperative
multitasking" from 1980's). In particular, I polled for mouse down and
mouse up events.

Later on, when the program is not doing anything, it makes sense to have
it wait for an event (rather than burn CPU by busy-waiting and polling).
BUT, since there is no way to empty the event queue, as far as I can
tell, the events that were polled during the first part will still be
sitting in the queue. The program will react to them, again, and the
effect is that some things may happen twice instead of once, which of
course is annoying. (Note that keypresses _can_ be emptied from the
queue because there is the Graphics.keypressed function, but really one
should be able to empty the whole queue.)

If the above description is confusing, imagine the following scenario:
in certain cases you want to empty the event queue in order to prevent
the user from doing a dangerous thing. For example, if you are going to
ask him "are you sure you want to format the hard disk?" then you better
empty the queue, lest the user pressed 'y' before he saw the question.

This would all be very easily solved if the ocaml people added an
"empty_queue" function to the Graphics module. I looked at the source
code and it seems it would be easy to do. Pretty please.

Or am I missing something obvious?

Andrej Bauer


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-01-26  9:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-26  9:17 What the Graphics module is missing Andrej Bauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).