html text 默认选中,html - 如何在Shiny中默认选择verbatimTextOutput中的文本? - SO中文参考 - www.soinside.com...
感謝@ismirsehregal的幫助。在這里,我分享了這個(gè)問(wèn)題的解決方法。此答案在只讀模式下使用textAreaInput,而不是我最初要求的verbatimTextOutput。但是,我對(duì)textAreaInput的結(jié)果和最終外觀感到滿意。library(shiny)
ui
fluidPage(
column(
width = 6,
tags$head(
tags$script("
Shiny.addCustomMessageHandler('selectText', function(message) {
$('#txt_out').select();
$('#txt_out').prop('readonly', true);
});
")
),
textInput(inputId = "txt", label = "Type in some texts",
value = paste0(rep(letters, 10), collapse = "")),
textAreaInput("txt_out", label = "Show the texts", heigh = "300px"),
br(),
bookmarkButton()
)
)
}
server
observeEvent(input$txt, {
updateTextAreaInput(session = session, inputId = "txt_out", value = input$txt)
})
observeEvent(input$txt_out, {
session$sendCustomMessage("selectText", "select")
})
}
enableBookmarking("url")
shinyApp(ui, server)
這是應(yīng)用程序運(yùn)行時(shí)的外觀。
總結(jié)
以上是生活随笔為你收集整理的html text 默认选中,html - 如何在Shiny中默认选择verbatimTextOutput中的文本? - SO中文参考 - www.soinside.com...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: asp.netkg117《计算机网络》教
- 下一篇: 职称计算机应用能力考试模拟题,2016年