
mascot_popup_menu()
Source:vignettes/articles/guide-mascot_popup_menu.Rmd
guide-mascot_popup_menu.RmdThe studio guide for mascot_popup_menu().
The same page is read in the mascot studio.
mascot::mascot_studio(fn = "mascot_popup_menu")
It opens on this function's guide; change a control and watch the mascot.
From a click to your server
input$helper_menu
observeEvent()
update_mascot()
Long status
The menu opens from the mascot’s position on the screen and falls back to the opposite side when the chosen side has no room. A long status makes the mascot taller, so choose a corner, then open the live mascot’s menu to see where it lands.
Your server code for these items
For an item named finish and labelled “Finish review”,
the server can answer like this:
shiny::observeEvent(input$helper_menu, {
switch(input$helper_menu,
finish = mascot::update_mascot("helper", mood = "happy")
)
})input$<id>_menu vs
input$<id>_click. Menus never set
input$<id>_click; only mascot_action()
does. Choosing an item sets input$<id>_menu to the
chosen item’s id. Opening and closing the menu sends no Shiny input.
Supply menu items when setting options. Setting
disabled, direction, label or
tooltip requires items. To remove the click
behaviour, pass click = mascot_popup_menu() to
update_mascot().
Keyboard. Tab to the mascot’s menu button, then Enter or Space opens it; arrow keys move between items; Escape closes it.
Warnings, errors and common mistakes
mascot_popup_menu(c("has spaces" = "Action"))
mascot_popup_menu(c(about = "About"), "top")