Module type Ojw_button_sigs.​T

module type T = sig..end

Buttons are html elements with a state of pressed or unpressed and actions are generally coupled with a state (such as show/hide an element).

module D : Ojw_dom_sigs.T
module Alert : Ojw_alert_sigs.T
class type button_event = object..end

The type for event triggered by buttons.

module Event : sig..end

Specific events for alerts

val pre_press : 
  ?use_capture:bool ->
  #Dom_html.eventTarget Js.t ->
  button_event Js.t Lwt.t
val pre_unpress : 
  ?use_capture:bool ->
  #Dom_html.eventTarget Js.t ->
  button_event Js.t Lwt.t
val press : 
  ?use_capture:bool ->
  #Dom_html.eventTarget Js.t ->
  button_event Js.t Lwt.t
val unpress : 
  ?use_capture:bool ->
  #Dom_html.eventTarget Js.t ->
  button_event Js.t Lwt.t
val post_press : 
  ?use_capture:bool ->
  #Dom_html.eventTarget Js.t ->
  button_event Js.t Lwt.t
val post_unpress : 
  ?use_capture:bool ->
  #Dom_html.eventTarget Js.t ->
  button_event Js.t Lwt.t
val pre_presses : 
  ?cancel_handler:bool ->
  ?use_capture:bool ->
  D.element D.elt ->
  (button_event Js.t -> unit Lwt.t -> unit Lwt.t) ->
  unit Lwt.t

This event is triggered before the button is pressed.

val presses : 
  ?cancel_handler:bool ->
  ?use_capture:bool ->
  D.element D.elt ->
  (button_event Js.t -> unit Lwt.t -> unit Lwt.t) ->
  unit Lwt.t

This event is triggered when the button is pressed.

val post_presses : 
  ?cancel_handler:bool ->
  ?use_capture:bool ->
  D.element D.elt ->
  (button_event Js.t -> unit Lwt.t -> unit Lwt.t) ->
  unit Lwt.t

This event is triggered after the button is pressed.

val pre_unpresses : 
  ?cancel_handler:bool ->
  ?use_capture:bool ->
  D.element D.elt ->
  (button_event Js.t -> unit Lwt.t -> unit Lwt.t) ->
  unit Lwt.t

This event is triggered before the button is unpressed.

val unpresses : 
  ?cancel_handler:bool ->
  ?use_capture:bool ->
  D.element D.elt ->
  (button_event Js.t -> unit Lwt.t -> unit Lwt.t) ->
  unit Lwt.t

This event is triggered when the button is unpressed.

val post_unpresses : 
  ?cancel_handler:bool ->
  ?use_capture:bool ->
  D.element D.elt ->
  (button_event Js.t -> unit Lwt.t -> unit Lwt.t) ->
  unit Lwt.t

This event is triggered after the button is unpressed.

Types for buttons

class type button = object..end

The basic type for buttons.

The followings buttons use alerts. If you're not comfortable with alerts, you should read the doc about them first.

class type button_alert = object..end

This button trigger an alert.

class type button_dyn_alert = object..end

Same as above, but use dynamic alert instead.

Helpers for buttons

val closeable_by_click : D.element D.elt -> D.element D.elt

Same as closeable_by_click from the module Ojw_alert See also Ojw_alert .

Construction functions

val button : 
  ?set:Ojw_active_set.t ->
  ?pressed:bool ->
  ?predicate:(unit -> bool Lwt.t) -> D.element D.elt -> D.element D.elt

Provides behaviours of a basic button.

pressed indicates if the button is initially pressed or not. The parameter set can be used if you want to have only one button pressed as the same time of other buttons. (as radio buttons).

The function predicate is called before the button is pressed. If true is returned, so the button can be press, otherwise, the button stay unpressed.

val button_alert : 
  ?set:Ojw_active_set.t ->
  ?pressed:bool ->
  ?predicate:(unit -> bool Lwt.t) ->
  ?allow_outer_clicks:bool ->
  ?closeable_by_button:bool ->
  ?before:(D.element D.elt -> Alert.D.element Alert.D.elt -> unit) ->
  ?after:(D.element D.elt -> Alert.D.element Alert.D.elt -> unit) ->
  D.element D.elt ->
  Alert.D.element Alert.D.elt ->
  D.element D.elt * Alert.D.element Alert.D.elt

Provides behaviours of an alert button.

It works as alert from Ojw_alert. The first parameter corresponds to the button and the second, to the alert (button_alert elt elt_alert).

For the parameters set, predicate and pressed, see the description above.

For the parameters allow_outer_clicks, before and after, see the description from the module Ojw_alert See also Ojw_alert Ojw_alert.

val button_dyn_alert : 
  ?set:Ojw_active_set.t ->
  ?pressed:bool ->
  ?predicate:(unit -> bool Lwt.t) ->
  ?allow_outer_clicks:bool ->
  ?closeable_by_button:bool ->
  ?before:(D.element D.elt -> Alert.D.element Alert.D.elt -> unit Lwt.t) ->
  ?after:(D.element D.elt -> Alert.D.element Alert.D.elt -> unit Lwt.t) ->
  D.element D.elt ->
  Alert.D.element Alert.D.elt ->
  (D.element D.elt ->
   Alert.D.element Alert.D.elt ->
   Alert.Content.element Alert.Content.elt list Lwt.t) ->
  D.element D.elt * Alert.D.element Alert.D.elt

Provides behaviours of an dynamic alert button.

The parameters are the same as button_alert. The third parameter correponds to the function used to generate the dynamic content of the alert. See also Ojw_alert Ojw_alert.

Conversion functions

These functions check if the given element is an instance of specific button (button, button_alert or button_dyn_alert).

val to_button : D.element D.elt -> button Js.t
val to_button_alert : D.element D.elt -> button_alert Js.t
val to_button_dyn_alert : D.element D.elt -> button_dyn_alert Js.t