package lablgtk3-extras

  1. Overview
  2. Docs

Module OkeySource

Convenient functions to handle key press events in Lablgtk widgets.

Sourcetype modifier = Gdk.Tags.modifier
Sourceval set_default_modifiers : modifier list -> unit

Set the default modifier list. The first default value is [].

Sourceval set_default_mask : modifier list -> unit

Set the default modifier mask. The first default value is [`MOD2 ; `MOD3 ; `MOD4 ; `MOD5 ; `LOCK]. The mask defines the modifiers not taken into account when looking for the handler of a key press event.

Setting handlers for simple key press events.

Sourceval add : < connect : < destroy : callback:(unit -> unit) -> GtkSignal.id.. > ; event : GObj.event_ops ; get_oid : int.. > -> ?cond:(unit -> bool) -> ?mods:modifier list -> ?mask:modifier list -> Gdk.keysym -> (unit -> unit) -> unit

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

  • parameter remove

    when true, the previous handlers for the given key and modifier list are not kept.

  • parameter cond

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

  • parameter mods

    the list of modifiers. If not given, the default modifiers are used. You can set the default modifiers with function Okey.set_default_modifiers.

  • parameter mask

    the list of modifiers which must not be taken into account to trigger the given handler. mods and mask must not have common modifiers. If not given, the default mask is used. You can set the default modifiers mask with function Okey.set_default_mask.

Sourceval add_list : < connect : < destroy : callback:(unit -> unit) -> GtkSignal.id.. > ; event : GObj.event_ops ; get_oid : int.. > -> ?cond:(unit -> bool) -> ?mods:modifier list -> ?mask:modifier list -> Gdk.keysym list -> (unit -> unit) -> unit

It calls Okey.add for each given key.

Sourceval set : < connect : < destroy : callback:(unit -> unit) -> GtkSignal.id.. > ; event : GObj.event_ops ; get_oid : int.. > -> ?cond:(unit -> bool) -> ?mods:modifier list -> ?mask:modifier list -> Gdk.keysym -> (unit -> unit) -> unit

Like Okey.add but the previous handlers for the given modifiers and key are not kept.

Sourceval set_list : < connect : < destroy : callback:(unit -> unit) -> GtkSignal.id.. > ; event : GObj.event_ops ; get_oid : int.. > -> ?cond:(unit -> bool) -> ?mods:modifier list -> ?mask:modifier list -> Gdk.keysym list -> (unit -> unit) -> unit

It calls Okey.set for each given key.

Sourceval remove_widget : < connect : < destroy : callback:(unit -> unit) -> GtkSignal.id.. > ; event : GObj.event_ops ; get_oid : int.. > -> unit -> unit

Remove the handlers associated to the given widget. This is automatically done when a widget is destroyed but you can do it yourself.

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

Sourcetype handler
Sourcetype keyhit_spec
Sourcetype keyhit_state = (modifier list * Gdk.keysym) list
Sourceval ignored_keys : Gdk.keysym list ref

The keys which are ignored when they are pressed alone.

Sourcetype handler_tree_node =
  1. | Handler of handler
  2. | Node of handler_tree list
Sourceand handler_tree = {
  1. mutable hst_spec : keyhit_spec;
  2. mutable hst_v : handler_tree_node;
}
Sourceval set_handler_trees : ?stop:(modifier list * Gdk.keysym) -> (unit -> handler_tree list) -> ?f_display_state:(after_handler:bool -> keyhit_state -> unit) -> < misc : GObj.misc_ops ; event : GObj.event_ops.. > -> unit
Sourceval handler : ?cond:(unit -> bool) -> (unit -> unit) -> handler
Sourceval keyhit_spec : ?mods:modifier list -> ?mask:modifier list -> Gdk.keysym -> keyhit_spec
Sourceval handler_tree : ?mods:modifier list -> ?mask:modifier list -> Gdk.keysym -> handler_tree_node -> handler_tree
Sourceval reset_state : < misc : GObj.misc_ops.. > -> unit
Sourceval trees_of_list : (keyhit_state * (unit -> unit)) list -> handler_tree list