# NOT RUN {
if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(
useShinyjs(), # Set up shinyjs
p(id = "myel", "Hover over me to see the date, the time, and a random integer"),
actionButton("remove_date", "Remove date hover event"),
actionButton("remove_all", "Remove all hover events")
),
server = function(input, output) {
onevent("hover", "myel", print(format(Sys.time(), "%H:%M:%S")))
onevent("hover", "myel", print(sample(100, 1)), add = TRUE)
date_event_id <- onevent("hover", "myel", print(as.character(Sys.Date())), add = TRUE)
observeEvent(input$remove_all, {
removeEvent("hover", "myel")
})
observeEvent(input$remove_date, {
removeEvent(date_event_id, "myel")
})
}
)
}
# }
Run the code above in your browser using DataLab