Bonsai_tui_click_handlerThis is a tiny library that implements on_click handlers in bonsai_term.
There is __no__ event bubbling, so when there are on_clicks attached on parent-child overlapping elements which handler will execute will be undefined behavior. Please only attach these to children-most, non-overlapping views.
val add_click_handler :
Bonsai_term.Bonsai.graph @ local ->
(Bonsai_term.View.t ->
on_click:unit Bonsai_term.Effect.t ->
Bonsai_term.View.t)
Bonsai_term.Bonsai.ton_click ~on_click view will trigger on_click if there are consecutive Left -> Release mouse events on view.
NOTE: In order for this library to do anything, you need to make a call to handler at the top-level of your app:
e.g.:
let ~view, ~handler = ... in
let handler = Aide_cli_click_handler.handler ~view ~handler graph in
~view, ~handlerval handler :
view:Bonsai_term.View.t Bonsai_term.Bonsai.t ->
handler:
(Bonsai_term.Event.t -> unit Bonsai_term.Effect.t) Bonsai_term.Bonsai.t ->
Bonsai_term.Bonsai.graph @ local ->
(Bonsai_term.Event.t -> unit Bonsai_term.Effect.t) Bonsai_term.Bonsai.tIn order for this library to work, you must add a call to handler at the top level of your app like:
let ~view, ~handler = ... in
let handler = Bonsai_tui_click_handler.handler ~view ~handler graph in
~view, ~handler