Hi,
I'm sorry but this is all still very confusing. I don't see what you want to accomplish here.
First of all, you declare all inputs yourself, so you can just write them out in your message:
observeEvent(input$button1, {
showModal(modalDialog(
title = "Button pressed",
"you pressed button 1, but here is a list of all inputs: button1, button2"
))
}, ignoreInit = T)
If you don't want to write them out (in case of many), you can list all the inputs as well:
# observe button 1 press.
observeEvent(input$button1, {
showModal(modalDialog(
title = "Button pressed",
paste("You pressed button 1, but here is a list of all inputs:",
paste(names(input), collapse = ", "))
))
}, ignoreInit = T)
Neither case will generate an action if you press button 2 through, it's just sitting there as a dummy.
In case you want to do the latter you can so this:
observeEvent(c(input$button1, input$button2), {
showModal(modalDialog(
title = "Button pressed",
paste("You pressed a button, but here is a list of all inputs:",
paste(names(input), collapse = ", "))
))
}, ignoreInit = T)
Or if you want to go crazy:
buttonClicked = reactiveValues(btn1 = 0, btn2 = 0)
observeEvent(c(input$button1, input$button2), {
if(input$button1 > buttonClicked$btn1){
buttonClicked$btn1 = buttonClicked$btn1 + 1
myButton = 1
} else {
buttonClicked$btn2 = buttonClicked$btn2 + 1
myButton = 2
}
showModal(modalDialog(
title = "Button pressed",
paste("You pressed button", myButton, ", but here is a list of all inputs:",
paste(names(input), collapse = ", "))
))
}, ignoreInit = T)
Hope any of these will help
PJ