问题描述
我正在努力在我的程序中实现 ShinyWidgets 下拉菜单,因为 A:它们看起来很棒B:它们很容易制作.
I am working on implementing shinyWidgets dropdown menus into my program because A: they look greatB: they are easy to make.
我无法解决的问题是如何让下拉菜单打开后工具提示消息消失.
The problem that I can't solve, is how to make the tooltip message disappear once the dropdownmenu is open.
小部件按钮的源代码如下:
the source code for the widget button is the following:
# tooltip
if (identical(tooltip, TRUE))
tooltip <- tooltipOptions(title = label)
if (!is.null(tooltip) && !identical(tooltip, FALSE)) {
tooltip <- lapply(tooltip, function(x) {
if (identical(x, TRUE))
"true"
else if (identical(x, FALSE))
"false"
else x
})
tooltipJs <- htmltools::tags$script(
sprintf(
"$('#%s').tooltip({ placement: '%s', title: '%s', html: %s, trigger: 'hover' });",
inputId, tooltip$placement, tooltip$title, tooltip$html
)
)
} else {
tooltipJs <- ""
}
我尝试了一个将延迟设置为 0 的解决方案,但它不起作用.
I tried a solution to set the delay to 0, but it doesn't work.
tooltip: { hideDelay: 0}
当小部件的模态对话框打开时,有人知道如何使弹出窗口消失吗?
Any one a clue how to make the popup disappear when modaldialog of the widget is open?
library("shiny")
library("shinyWidgets")
shinyApp(
ui = fluidPage(
tags$head(tags$style('#dropdown-menu-MyDDM {left: 100px;}
tooltip: {
hideDelay: 0
}')),
dropdownButton(label = "CLICK",
h5("HELLO"),
icon = icon("gear"),
# right = T,
inputId = "MyDDM",
circle = T, status = "info", size = "sm",
tooltip = tooltipOptions(title = "Click to change plot"), width = "600px")
),
server = function(input, output, session) {
}
)
推荐答案
shinyWidget
的开发版已经有了这个功能.
The development version of shinyWidget
has got this functionality.
可以这样安装:
# From Github
# install.packages("devtools")
devtools::install_github("dreamRs/shinyWidgets")
代码的变化是这样的:
- "$('#%s').tooltip({ placement: '%s', title: '%s', html: %s });",
+ "$('#%s').tooltip({ placement: '%s', title: '%s', html: %s, trigger: 'hover' });",
最终为指定的 css 类推送此工具提示.
Which ultimately pushes this tooltip for the assigned css class.
这篇关于打开时shinyWidget下拉按钮的bstooltip不会消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!