package bogue

  1. Overview
  2. Docs

Module Bogue.TriggerSource

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

SDL events

Sourceval text_input : t

Same as Tsdl.Sdl.Event.text_input

Sourceval key_down : t

Same as Tsdl.Sdl.Event.key_down

Sourceval key_up : t

Same as Tsdl.Sdl.Event.key_up

Special Bogue events

Sourceval startup : t

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

Sourceval 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.

Sourceval mouse_leave : t

Similar to mouse_enter, when the pointer leaves the layout.

Sourceval mouse_at_rest : t

Triggered when the mouse did not move for a while.

Sourceval var_changed : t

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

Sourceval update : t

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

Sourceval user_event : t

Same as Tsdl.Sdl.Event.user_event. This special event of type SDL_UserEvent can trigger a global reaction, not associated with any widget in particular, through the on_user_event parameter of Main.create

Sourceval buttons_down : t list

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

Sourceval buttons_up : t list

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

Sourceval pointer_motion : t list

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

Using events for terminating threads

Sourceval 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.

Sourceval will_exit : Tsdl.Sdl.event -> unit

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

Sourceval 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.

Sourceval 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.

Sourceval wait_for : ?timeout:float -> ?ev:Tsdl.Sdl.event -> (unit -> bool) -> unit

SDL Misc

SDL events

Sourcetype sdl_event = Tsdl.Sdl.Event.enum
Sourcetype bogue_event = [
  1. | `Bogue_startup
  2. | `Bogue_stop
  3. | `Bogue_stopped
  4. | `Bogue_mouse_at_rest
  5. | `Bogue_mouse_enter
  6. | `Bogue_mouse_leave
  7. | `Bogue_var_changed
  8. | `Bogue_keyboard_focus
  9. | `Bogue_mouse_focus
  10. | `Bogue_remove_focus
  11. | `Bogue_destroy_window
  12. | `Bogue_update
  13. | `Bogue_sync_action
  14. | `Bogue_redraw
  15. | `Bogue_keymap_changed
  16. | `Bogue_add_window
  17. | `SDL_POLLSENTINEL
]
Sourceval event_kind : Tsdl.Sdl.event -> [ sdl_event | bogue_event ]

Union of sdl_event and bogue_event

OCaml

Innovation. Community. Security.