r-world-devs / shinyGizmo

https://r-world-devs.github.io/shinyGizmo
Other
19 stars 0 forks source link

Add function that informs whether input was updated by user or programmatically + extra controllers #20

Open krystian8207 opened 2 years ago

krystian8207 commented 2 years ago

Sth like:

UI:

controlInput(
  selectInput("letter", "Letter", letters),
  block_user = TRUE/FALSE, # should the input value in server be blocked when updated by user
  block_program = TRUE/FALSE, # should the input value in server be blocked when updated by update* method
  attach_attributes = c(_trigger = TRUE, attrib_name = attrib_value) # attach attributes to the input value (some specials i.e. _trigger that tells whether send by user or update* or custom ones, e.g. class = "form_input")
)

Server:

str(input$letter)
> chr "a"
> - attr(*, "_trigger")= chr "user"

Implementation idea:

  1. Add proper class to the input.
  2. Mark input properly with shiny:inputchanged and shiny:updateinput (+ use event.stopPropagation() where needed).
  3. Attach attributes with registerInputHandlers when loading the package.

Probable issue: To use registerInputHandlers we need to rewrite binding class, is it possible with keeping the standard logic unchanged?