package stk

  1. Overview
  2. Docs

Convenient functions to handle key press events in widgets.

Setting handlers for simple key press events.

val add : Widget.widget -> ?cond:(unit -> bool) -> Key.keystate -> (unit -> unit) -> unit

add widget keystate callback associates the callback function to the event "key_press" with the given keystate for the given widget.

The optional parameter conf is a guard: the callback function is not called if the cond function returns false. The default cond function always returns true.

val add_list : Widget.widget -> ?cond:(unit -> bool) -> Key.keystate list -> (unit -> unit) -> unit

add_list widget ?cond list callback calls add widget ?cond ks callback for each keystate ks of the given list.

val set : Widget.widget -> ?cond:(unit -> bool) -> Key.keystate -> (unit -> unit) -> unit

Like add but the previous handlers for the given keystate are not kept.

val set_list : Widget.widget -> ?cond:(unit -> bool) -> Key.keystate list -> (unit -> unit) -> unit

set_list widget ?cond list callback calls set widget ?cond ks callback for each keystate ks of the given list.

Setting handlers for combination of key press events, a la emacs

type handler
val ignored_keys : Tsdl.Sdl.keycode list ref

The keys which are ignored when they are pressed alone.

type keyhit_state = (Tsdl.Sdl.keymod * Tsdl.Sdl.keycode) list
type handler_tree_node =
  1. | Handler of handler
  2. | Node of handler_tree list
and handler_tree = {
  1. mutable hst_spec : Key.keystate;
  2. mutable hst_v : handler_tree_node;
}
val string_of_handler_trees : handler_tree list -> string
val pp_handler_trees : Format.formatter -> handler_tree list -> unit
val reset_state : Widget.widget -> unit
val set_handler_trees : ?stop:Key.keystate -> (unit -> handler_tree list) -> ?display_state:(after_handler:bool -> keyhit_state -> unit) -> Widget.widget -> unit
val handler : ?cond:(unit -> bool) -> (unit -> unit) -> handler
val trees_of_list : (Key.keystate list * (unit -> unit)) list -> handler_tree list
val string_of_keyhit_state : keyhit_state -> string
val pp_keyhit_state : Format.formatter -> keyhit_state -> unit
OCaml

Innovation. Community. Security.