From murdoch at stats.uwo.ca  Thu Dec  9 19:55:05 2004
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Thu Dec  9 19:55:14 2004
Subject: [Rd] pausing between plots - waiting for graphics input
In-Reply-To: <41ACE709.1090205@stat.auckland.ac.nz>
References: <1101582479.13352.37.camel@horizons.localdomain>	<b68812e704112718032d3cf7d8@mail.gmail.com>	<vuhiq095lke0trblge8161b3dakaubg776@4ax.com>	<2kpjq0p9bq1i8b2258rl71bds4k9bg83fq@4ax.com>	<Pine.A41.4.61b.0411290912110.88302@homer09.u.washington.edu>	<16812.22791.971545.79304@gargle.gargle.HOWL>
	<jrnoq05l7bk577i9agfjctgh8k2jq8ls7m@4ax.com>
	<41ACD02F.4000105@stat.auckland.ac.nz>
	<rdmpq0p3b38fk1vupird057t7bnha2kf5f@4ax.com>
	<41ACE709.1090205@stat.auckland.ac.nz>
Message-ID: <ct6hr0t2f4o20va9c1et3ncfqg5f0pvun4@4ax.com>

On Wed, 01 Dec 2004 10:32:57 +1300, Paul Murrell
<p.murrell@auckland.ac.nz> wrote :

>Hi
>
>
>Duncan Murdoch wrote:
>> On Wed, 01 Dec 2004 08:55:27 +1300, Paul Murrell
>> <p.murrell@auckland.ac.nz> wrote :
>> 
>> 
>>>This sounds like the general problem of being able to capture keyboard 
>>>input on a graphics device (a key-stroke equivalent of dev_locator). 
>>>Robert has been keen on this for a while too.

I've now committed the getGraphicsEvent function with mouse and
keyboard support.  So far only the windows screen device knows how to
work with it, because that's all I've got.  It's in the R-devel build
I just uploaded, which should be downloadable by tomorrow.

If someone wants to write support for other platforms, I'd be happy to
help.  I imagine the implementation will change a bit when we do the
first one, because I don't know the other platforms at all, and have
probably made some Windows-centric assumptions.  But at least it's a
starting point.

Here's a quick summary of how it currently looks:

The device is assumed to be based on the NewDevDesc structure.  There
are new fields canGenXXX to indicate that it can generate mouse or
keyboard events; getGraphicsEvent aborts if you try to set an event on
a device that doesn't support them.

When getGraphicsEvent is active, it sets a gettingEvent field to TRUE,
saves its environment into eventRho, and calls the getEvent callback.
This callback is supposed to run an event loop, looking for user
input.  When it sees an event that it is supposed to handle, it calls
a doMouseXXX or doKeybd function, and those translate the message into
an R call to call the handler, and put the result in eventResult.  

The whole process can be aborted if the user interrupts (e.g. by
hitting Esc in Rgui); in that case, another callback called onExit is
called to clean up.

Comments are welcome.

Duncan Murdoch


[Rd] pausing between plots - waiting for graphics input
Duncan Murdoch