在gWidgetsRGtk2中更改小部件的鼠标光标 [英] Change mouse cursor of a widget in gWidgetsRGtk2

查看:180
本文介绍了在gWidgetsRGtk2中更改小部件的鼠标光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将鼠标光标更改为手,以单击图像.

I want to change the mouse cursor to a hand, for clicking an image.

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

我已经阅读了其他相关文章,但setCursor在小部件上不起作用.

I have read other post related but setCursor doesn't work on Widgets.

谢谢

推荐答案

在这里查看(

Looking here (how can i change the shape mouse cursor in gWidgets RGtk2?) you can see what you need for RGtk2. Try this:

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上可以使用.如果它对您不起作用,您能指出您尝试使用的是哪个操作系统吗?

That works under Mac OS X. If it doesn't work for you, can you indicate which OS you are trying?

这篇关于在gWidgetsRGtk2中更改小部件的鼠标光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆