Skip to content

Instantly share code, notes, and snippets.

@zappingseb
Created October 3, 2018 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zappingseb/83f0972a4a0c964e9bb5d76d0d42ae2b to your computer and use it in GitHub Desktop.
Save zappingseb/83f0972a4a0c964e9bb5d76d0d42ae2b to your computer and use it in GitHub Desktop.
# Try to remove the input Handler as shiny does not allow double input
# handlers
try({ removeInputHandler("DoubleColorPickerBinding") })
# Use the shiny registerInputHandler function to
# register a way to deal with the inputs coming
shiny::registerInputHandler(
"DoubleColorPickerBinding",
function(x, shinysession, name) {
if(is.null(x)) {
return(x)
} else {
# Parse return value from JSON into R format dataframe
colors_df <- jsonlite::fromJSON(x)
# Extract the values of the data frame as a list
res <- list()
res[["fill"]] <- colors_df$value[
which(grepl(colors_df$name,pattern="fill"))
]
res[["border"]] <- colors_df$value[
which(grepl(colors_df$name,pattern="border"))
]
return(res)
}
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment