开发者

How to check position of mouse poiner in R ? Is there any function for that?

How to che开发者_如何转开发ck position of mouse pointer in R ? Is there any function for that ? I know about locator() etc. but body of that function doesn't contain any useful information for the question I've asked, is it possible for R to report position of mouse pointer not only in R window ?


Look at getGraphicsEvent. Try help(getGraphicsEvent).


You can do this with the cairoDevice package:

library(RGtk2)
library(cairoDevice)

da <- gtkDrawingArea()
asCairoDevice(da)
da$AddEvents(GdkEventMask["all-events-mask"])

w <- gtkWindow(show=FALSE)
w$add(da)
w$show()

hist(rnorm(100))

gSignalConnect(da, "motion-notify-event", function(w, e) {
  print(c(e$x, e$y))
  invisible(TRUE)
})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜