Last active
June 3, 2017 15:28
-
-
Save timelyportfolio/b5c04ea4b1a4dcbf1128f7da1d79770b to your computer and use it in GitHub Desktop.
right click in RStudio Viewer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(htmltools) | |
# using discussion from https://stackoverflow.com/questions/2973321/javascript-capturing-right-click-and-disabling-menu-only-within-certain-element | |
browsable( | |
tagList( | |
tags$div(id="divctx","right click me"), | |
tags$script( | |
" | |
$('#divctx').bind('contextmenu', function(e) { | |
// do stuff here instead of normal context menu | |
alert('right click'); | |
return false; | |
}); | |
" | |
), | |
rmarkdown::html_dependency_jquery() | |
) | |
) | |
library(htmltools) | |
browsable( | |
tagList( | |
tags$head( | |
tags$script(src="//cdn.jsdelivr.net/gh/mar10/jquery-ui-contextmenu@v1/jquery.ui-contextmenu.min.js") | |
), | |
tags$div(id="divctx","right click me"), | |
tags$script( | |
' | |
$(document).contextmenu({ | |
delegate: "#divctx", autoFocus: true, | |
preventContextMenuForPopup: true, | |
preventSelect: true, | |
taphold: true, | |
menu: [ | |
{title: "Cut <kbd>Ctrl+X</kbd>", cmd: "cut", uiIcon: "ui-icon-scissors"}, | |
{title: "Copy <kbd>Ctrl+C</kbd>", cmd: "copy", uiIcon: "ui-icon-copy"} | |
] | |
}) | |
' | |
), | |
rmarkdown::html_dependency_jquery(), | |
rmarkdown::html_dependency_jqueryui() | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i think i read in a thread yesterday that you can force the default context menu to have 100% opacity, that way only the user defined one is showing. (right now the rstudio one comes over the one you wrote in)