在gWidgetsRGtk2中更改窗口小部件的鼠标光标

时间:2013-07-15 15:29:46

标签: r gwidgets

我想将鼠标光标更改为手,以便点击图像。

hlp<-gimage("help", dirname="stock", size="dialog")
addHandlerClicked(hlp, handler=function(h,...) {
   browseURL("http://....")})

我已阅读其他相关帖子,但setCursor并不适用于小部件。

谢谢

1 个答案:

答案 0 :(得分:0)

在这里(how can i change the shape mouse cursor in gWidgets RGtk2?),你可以看到你对RGtk2的需求。试试这个:

library(RGtk2)
w <- gwindow()
g <- ggroup(cont=w)
gbutton("button", cont=g)
img <- gimage("/Users/verzani/bubble-gum-art.jpg", cont=g)
old_cursor <- getToolkitWidget(img)$getWindow()$getCursor()
cross <- gdkCursorNew("GDK_TCROSS")

addHandler(img, "enter-notify-event", handler=function(h,...) {
           getToolkitWidget(img)$getWindow()$setCursor(cross)
           TRUE
           })


addHandler(img, "leave-notify-event", handler=function(h,...) {
           getToolkitWidget(img)$getWindow()$setCursor(old_cursor)
           TRUE
           })

在Mac OS X下运行。如果它不适合你,你能说明你正在尝试哪个操作系统吗?

相关问题