package bogue

  1. Overview
  2. Docs

Dealing with events

Events are simply SDL events, plus a few additional events. They are also used for primitive communication between threads.

Events are detected by Layouts, and then sent to the resident Widget. Finally, the Widget decides what to do with the events. There is one exception: the startup event is directly sent to all Widgets.

Dependency graph

Special Bogue events

val startup : t

The startup event is sent to all Widgets when the Bogue mainloop is started using Main.run.

val mouse_enter : t

The mouse_enter event is triggered when the pointer (mouse motion, or finger touch -- but not finger drag) enters a new layout.

val mouse_leave : t

Similar to mouse_enter, when the pointer leaves the layout.

val var_changed : t

The var_changed event can be sent to notify that some widget made a change to a global variable.

val update : t

Currently the update event is more or less equivalent to var_changed. This might change in future versions.

val buttons_down : t list

A list of events containing the mouse_button_down event, and the finger_down event.

val buttons_up : t list

A list of events containing the mouse_button_up event, and the finger_up event.

val pointer_motion : t list

A list of events containing the mouse_motion event, and the finger_motion event.

Using events for terminating threads

val should_exit : Tsdl.Sdl.event -> bool

Tell if the current thread should exit. This should only be called within a widget action. The event should be the event passed to the action function. A well programmed action should check this event to decide if it should exit.

val will_exit : Tsdl.Sdl.event -> unit

A nice thread should do this just before terminating. May be suppressed in future versions.

val nice_delay : Tsdl.Sdl.event -> float -> unit

nice_delay ev t Wait during a delay (t seconds), but quit anyway when {!should_exit} ev is true.

val push_quit : unit -> unit

Send the SDL_QUIT event, as if the user clicked on the close button of the last existing window. It will in principle raise the Main.Exit exception and hence exit the mainloop.

SDL events

type sdl_event = [
  1. | `App_did_enter_background
  2. | `App_did_enter_foreground
  3. | `App_low_memory
  4. | `App_terminating
  5. | `App_will_enter_background
  6. | `App_will_enter_foreground
  7. | `Clipboard_update
  8. | `Controller_axis_motion
  9. | `Controller_button_down
  10. | `Controller_button_up
  11. | `Controller_device_added
  12. | `Controller_device_remapped
  13. | `Controller_device_removed
  14. | `Dollar_gesture
  15. | `Dollar_record
  16. | `Drop_file
  17. | `Finger_down
  18. | `Finger_motion
  19. | `Finger_up
  20. | `Joy_axis_motion
  21. | `Joy_ball_motion
  22. | `Joy_button_down
  23. | `Joy_button_up
  24. | `Joy_device_added
  25. | `Joy_device_removed
  26. | `Joy_hat_motion
  27. | `Key_down
  28. | `Key_up
  29. | `Mouse_button_down
  30. | `Mouse_button_up
  31. | `Mouse_motion
  32. | `Mouse_wheel
  33. | `Multi_gesture
  34. | `Quit
  35. | `Sys_wm_event
  36. | `Text_editing
  37. | `Text_input
  38. | `Unknown of int
  39. | `User_event
  40. | `Window_event
]
type bogue_event = [
  1. | `Bogue_startup
  2. | `Bogue_stop
  3. | `Bogue_stopped
  4. | `Bogue_mouse_at_rest
  5. | `Bogue_full_click
  6. | `Bogue_mouse_enter
  7. | `Bogue_mouse_leave
  8. | `Bogue_var_changed
  9. | `Bogue_keyboard_focus
  10. | `Bogue_update
  11. | `Bogue_sync_action
  12. | `Bogue_redraw
]
val event_kind : Tsdl.Sdl.event -> [> sdl_event | bogue_event ]
OCaml

Innovation. Community. Security.