You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since I had problems with threads, and since the required feature does
not really need threads, I've done a little patch to the Graphics module.
Well, in fact, the X11 version of the Graphics module. Someone needs to fix
this for Win32.
A new Timeout of float constructor is available in the Graphics.event type :
type event =
Button_down (** A mouse button is pressed )
| Button_up (* A mouse button is released )
| Key_pressed (* A key is pressed )
| Mouse_motion (* The mouse is moved )
| Poll (* Don't wait; return immediately )
| Timeout of float (* No event occurs in the specified number of
seconds *)
A new timedout field has been added to Graphics.status record type :
type status =
{ mouse_x : int; (** X coordinate of the mouse )
mouse_y : int; (* Y coordinate of the mouse )
button : bool; (* true if a mouse button is pressed )
keypressed : bool; (* true if a key has been pressed )
key : char; (* the character for the key pressed )
timedout : bool; (* true only if no event occured in the given
time *)
}
will return when the mouse is moved, a key is pressed or if 3 seconds
pass, whichever comes first. In the first two cases, the timedout
field will be false. In the last case, it will be true and other
fields will be meaningless (zero or false, actually).
Original bug ID: 1393
Reporter: administrator
Status: closed
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Berke Durak
Version: 3.06
OS: Linux
Submission from: mix-montsouris-113-2-170.abo.wanadoo.fr (80.9.109.170)
Hello,
Since I had problems with threads, and since the required feature does
not really need threads, I've done a little patch to the Graphics module.
Well, in fact, the X11 version of the Graphics module. Someone needs to fix
this for Win32.
A new Timeout of float constructor is available in the Graphics.event type :
type event =
Button_down (** A mouse button is pressed )
| Button_up (* A mouse button is released )
| Key_pressed (* A key is pressed )
| Mouse_motion (* The mouse is moved )
| Poll (* Don't wait; return immediately )
| Timeout of float (* No event occurs in the specified number of
seconds *)
A new timedout field has been added to Graphics.status record type :
type status =
{ mouse_x : int; (** X coordinate of the mouse )
mouse_y : int; (* Y coordinate of the mouse )
button : bool; (* true if a mouse button is pressed )
keypressed : bool; (* true if a key has been pressed )
key : char; (* the character for the key pressed )
timedout : bool; (* true only if no event occured in the given
time *)
}
For example the expression
will return when the mouse is moved, a key is pressed or if 3 seconds
pass, whichever comes first. In the first two cases, the timedout
field will be false. In the last case, it will be true and other
fields will be meaningless (zero or false, actually).
The patch is available at
Apply it by typing (sorry I'm not an expert in making patches, hope this is
correct)
assuming that your Ocaml sources are in /usr/local/src/ocaml-3.06 and
that the patch is /path/ocaml-306-graph.patch.
I guess it will work with previous versions.
Note that it seems that recompiling the whole Ocaml is unnecessary ;
just type
cd /usr/local/src/ocaml-3.06/otherlibs/graph && make && make allopt && make
install.
Now I can concentrate on implementing ``Standard Tetris'' !!
The text was updated successfully, but these errors were encountered: