0

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://....")})

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

Thank you

JJChickpeaboy
  • 55
  • 1
  • 5

1 Answers1

0

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
           })

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

Community
  • 1
  • 1
jverzani
  • 5,600
  • 2
  • 21
  • 17
  • I'm using Linux and it works, but it set the hand cursor for all the window and I wanted just for the image. By the way, thanks for your efforts. – JJChickpeaboy Jul 16 '13 at 07:45
  • Thanks for pointing that out. The example is edited now to work around that. – jverzani Jul 16 '13 at 15:18