[R] tcltk: repeat event while button is down?

2004-08-05 Thread Duncan Murdoch
Is there a way in TCL/TK to trigger an event multiple times while a
button is held down?  I'd like to have an rgl scene continuously
rotate until the button is released.

Duncan Murdoch

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] tcltk: repeat event while button is down?

2004-08-05 Thread Peter Dalgaard
Duncan Murdoch [EMAIL PROTECTED] writes:

 Is there a way in TCL/TK to trigger an event multiple times while a
 button is held down?  I'd like to have an rgl scene continuously
 rotate until the button is released.

Something involving after, I'd say. Set up the rotate action to
reschedule itself after N milliseconds, and the button release event
to after cancel. 


Or, perhaps safer, set a flag and condition the after command on it.

I.e. something like

doit - function() if(flag){rotate(); tkcmd(after,5,doit)}

on button press, 

flag - TRUE ; doit()

and on button release

flag - FALSE
   
That method has the drawback that one rotate() will occur after the
button release. 

The first suggestion would amount to

doit - function() {rotate(); ID - tkcmd(after,5,doit)}

and then on button press (watch the scoping issues)

ID - 
doit()

and on release

tkcmd(after,cancel,ID)

which I think does work in pure Tcl, but I suspect that it in the
Windows implementation of R-Tcl can cause race conditions so that the
ID variable is outdated when the cancel takes place (Tcl guarantees
that scripts execute atomically; as it turns out, for good
reasons...). 

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] tcltk: repeat event while button is down?

2004-08-05 Thread Duncan Murdoch
On 05 Aug 2004 22:55:10 +0200, Peter Dalgaard
[EMAIL PROTECTED] wrote :

Duncan Murdoch [EMAIL PROTECTED] writes:

 Is there a way in TCL/TK to trigger an event multiple times while a
 button is held down?  I'd like to have an rgl scene continuously
 rotate until the button is released.

Something involving after, I'd say. Set up the rotate action to
reschedule itself after N milliseconds, and the button release event
to after cancel. 

Thanks.  Just one more detail:  the docs I have must be old, they
don't talk about separate button press and button release events.  How
do I attach separate event handlers to those?

Duncan

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] tcltk: repeat event while button is down?

2004-08-05 Thread Peter Dalgaard
Duncan Murdoch [EMAIL PROTECTED] writes:

 On 05 Aug 2004 22:55:10 +0200, Peter Dalgaard
 [EMAIL PROTECTED] wrote :
 
 Duncan Murdoch [EMAIL PROTECTED] writes:
 
  Is there a way in TCL/TK to trigger an event multiple times while a
  button is held down?  I'd like to have an rgl scene continuously
  rotate until the button is released.
 
 Something involving after, I'd say. Set up the rotate action to
 reschedule itself after N milliseconds, and the button release event
 to after cancel. 
 
 Thanks.  Just one more detail:  the docs I have must be old, they
 don't talk about separate button press and button release events.  How
 do I attach separate event handlers to those?

ButtonPress-1 (or just 1), ButtonRelease-1, I believe. It's used
in the tkcanvas demo.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html