clipCodeButton: Add button to copy text to clipboard

Description Usage Arguments Value Examples

Description

Add button to copy text to clipboard

Usage

1
2
3
clipCodeButton(server, label = NULL, icon = NULL, modal = FALSE,
  id = "clipboard_btn", envir = parent.frame(), text = get_code(server,
  envir = envir))

Arguments

server

server function to derive code from

label

a button label to be displayed with the button

icon

an icon to be displayed with the button

modal

whether the button is being shown in a modal dialog

id

button css id

envir

environment from which code should be collected

text

the text to be copied

Value

a shiny tagList containing the button

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
library(shiny)

ui <- fluidPage(
  scriptglossJS(),
  selectInput('x', 'x axis', choices = names(mtcars)),
  selectInput('y', 'y axis', choices = names(mtcars)),
  uiOutput('copy_code_btn'),
  plotOutput('plot')
)

srv <- function(input, output, session) {
  output$plot <- renderPlot({
    plot(x = mtcars[[input$x]],
         y = mtcars[[input$y]])
  })
  output$copy_code_btn <- renderUI(clipCodeButton(srv))
}

shinyApp(ui, srv)

## End(Not run)

dgkf/scriptgloss documentation built on June 8, 2019, 8:43 p.m.