I had a small questions. I have tried researching this a lot but I have had no luck. Is there a way R-shiny has to capture a double click on an element like a button.
Here is one way to do it. The key is to detect the dblclick
event on the client side (i.e. ui), and then invoke Shiny.onInputChange
to update the value of an R variable, which can then be picked up by the server.
Here is what happens when the button is double clicked.
x
.x
textOutput
.library(shiny) ui = bootstrapPage( tags$button(id = 'mybutton', 'button', class='btn btn-primary', value = 0), textOutput('x'), # when button is double clicked increase the value by one # and update the input variable x tags$script(" $('#mybutton').on('dblclick', function(){ var val = +this.value this.value = val + 1 Shiny.onInputChange('x', this.value) console.log(this.value) }) ") ) server = function(input, output, session){ output$x <- renderText({ input$x }) } runApp(list(ui = ui, server = server))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With