JSを追加することでそれを行うことができます
みたいな
$(document).on('click', '.needed', function () {
Shiny.onInputChange('last_btn',this.id);
});
needed
例 (すべての btn を制御したくない場合は、btnにクラスを追加します)
ui <- shinyUI(fluidPage(
titlePanel("Track last clicked Action button"),
tags$head(tags$script(HTML("$(document).on('click', '.needed', function () {
Shiny.onInputChange('last_btn',this.id);
});"))),
sidebarLayout(
sidebarPanel(
actionButton("first", "First",class="needed"),
actionButton("second", "Second",class="needed"),
actionButton("third", "Third",class="needed"),
actionButton("save", "save"),
selectInput("which_","which_",c("first","second","third"))
),
mainPanel(
textOutput("lastButtonCliked")
)
)
))
server <- shinyServer(function(input, output,session) {
observeEvent(input$save,{
updateSelectInput(session,"which_",selected = input$last_btn)
})
output$lastButtonCliked=renderText({input$last_btn})
})
# Run the application
shinyApp(ui = ui, server = server)