Skyline_menu_v2SourceA menu displays a list of actions in a popover. It can be attached to any element and triggered via click or right-click.
Example
let menu = Skyline_menu_v2.controller graph in
let options =
let%arr action_1 and action_2 in
{%html|
<Skyline_menu_v2.Options.create>
<Skyline_menu_v2.Options.item ~key:%{"action-1"} ~on_click:%{action_1}>
Action 1
</>
<Skyline_menu_v2.Options.item ~key:%{"action-2"} ~on_click:%{action_2}>
Action 2
</>
</>
|}
in
let%arr menu and options in
{%html|
<div %{Skyline_menu_v2.on_contextmenu menu ~options:(Effect.return options)}>
Right click on me!
</div>
|}Menu options express a collection of actions. See Options for how to build the list of menu items.
t holds the menu's state and a setter to control it.
state is the current state of the menu (open or closed)set_state allows you to programmatically open or close the menuval controller :
?size:Skyline_size.t Bonsai_web.Bonsai.t ->
?position:Position.t Bonsai_web.Bonsai.t ->
?alignment:Alignment.t Bonsai_web.Bonsai.t ->
?state:
(State.t Bonsai_web.Bonsai.t
* (State.t -> unit Bonsai_web.Effect.t) Bonsai_web.Bonsai.t) ->
Bonsai_web.Bonsai.graph @ local ->
t Bonsai_web.Bonsai.tCreates a menu t that can be attached to elements via on_click or on_contextmenu.
?size controls the size of the menu items (defaults to `Md)?position sets the popover position relative to the anchor (defaults to Auto)?alignment sets the popover alignment relative to the anchor (defaults to Start)?state allows controlling the menu state externallyval on_click :
?open_at:Open_at.t ->
t ->
options:Options.t Bonsai_web.Effect.t ->
Bonsai_web.Vdom.Attr.tCreates an attr that binds an on_click event to open the menu.
?open_at controls where the menu appears: Cursor positions it at the cursor location, Anchor positions it relative to the anchor element (default is Cursor)Creates an attr that binds an on_contextmenu (right-click) event to open the menu.
?open_at controls where the menu appears: Cursor positions it at the cursor location, Anchor positions it relative to the anchor element (default is Cursor)