R/eventsButton.R

Defines functions eventsButton

Documented in eventsButton

#' eventsButton
#' 
#' A button that responds to events click, doubleclick, hover etc. It's built on
#' top of actionButton and eventInput
#' 
#' @param events A sequence of events that will invalidate the button
#'   \url{http://getbootstrap.com/2.3.2/base-css.html#icons}
#' @rdname actionButton
#' 
#' @examples 
#' 
#' # simply use this in place of a actionButtion
#' # change the event to "hover" "mousedown" etc
#' # see full list https://api.jquery.com/category/events/mouse-events/
#' eventsButton("inputId", "label", events = c("dblclick"))
#' 
#' @export
eventsButton <- function(..., events = c("dblclick")) {
    
    b <- actionButton(..., css.class = "shinysky-eventinput", 
        `data-shinysky-event-count` = 0, `data-shinysky-last-event` = "", 
        `data-shinysky-monitored-events` = paste(events, collapse = " "))
    return(shiny::tagList(shiny::singleton(shiny::tags$script(src = "shinysky/event-input.js")), 
        b))
} 
AnalytixWare/ShinySky documentation built on March 2, 2020, 6:10 p.m.