Created attachment 2105 [details]
patch to enable Cairo support for getGraphicsEvent, and implement onIdle
Here's a patch for a couple of features as discussed recently on the R-devel list (https://stat.ethz.ch/pipermail/r-devel/2016-June/072811.html).
Problem #1, lack of Cairo support in getGraphicsEvent, was fixed in a patch in bug 14364; strangely enough that bug was closed and the patch was never applied. The bug was fixed by generating an error when Cairo is used with getGrahpicsEvent; the reporter's patch would have just made Cairo *work* with getGraphicsEvent...
I solve Problem #2, the ability to use getGraphicsEvent asynchronously, with the suggestion I made in the follow-up to the above message - via the implementation of an "onIdle" handler in the getGraphicsEvent interface.
The changes for Problem #1 were essentially the same as those in the patch of Hugo's bug 14364, but I also updated the documentation to say that Cairo is now supported.
I have combined both sets of changes into a single patch, since the Cairo changes are dwarfed by the onIdle changes. Let me know if it would be helpful to have them separated out.
This is the largest patch I've submitted to R. Whoever applies it may want to delete some of my comments, or let me know if other changes need to be made. Or whatever. I tested it enough to satisfy myself that it works.
Hope everything is well. Thank you. Clicking "submit" now...
Would you be able to send some example test code for your #2 fix ?
i.e., some examples of the use of 'onIdle' (along with a description of expected behaviour)
Created attachment 2181 [details]
example code for onIdle
Examples for onIdle code
I sent this to r-devel but also wanted to post it here since Paul asked for it here. I'm not sure if I'm getting Cc'ed when someone comments on this bug so please bear with me.
Created attachment 2182 [details]
Example of an interactive histogram using getGraphicsEvent
I've added a simple example to produce an interactive histogram, where we can click on the bars to highlight them (actually just using the horizontal position of the click --doesn't have to be on the bar).
Created attachment 2183 [details]
Example of an interactive histogram controlling a scatterplot using getGraphicsEvent
This second example is similar to the first, but uses the interactive histogram to highlight points in a scatterplot on another device. This is slightly hacky because it relies on the device numbers remaining the same.
I don't really have any useful suggestions for unit testing of the interactive graphics functionality, but these examples might be useful for the help files.
Patch applied in r-devel r72261