[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-sig-mac
Subject:    Re: [R-SIG-Mac] R base functions from R.app (bringToTop)
From:       Atul Sharma <atul.sharma () mcgill ! ca>
Date:       2009-03-16 5:27:29
Message-ID: 0E5DFA1F-DBF2-48C4-974B-6B4EA62C8932 () mcgill ! ca
[Download RAW message or body]

To reproduce a reasonable facsimile of the 'bringToTop()' function  
that is part of the auto-loaded grDevices package on other platforms,  
define the following function in your RProfile.site file (to run at  
start-up)

bringToTop<-function(which=dev.cur()) {system("osascript ~/Library/ 
Scripts/RScripts/RBringToTop.scpt")}

The path to the Applescript that is invoked via osascript may vary  
depending on where you store the following Applescript. Note that I  
don't use X11 display, so I am only applying 'bringToTop' to quartz  
graphic windows and R Console. The extension to X11cairo devices   
(duplicating the second tell block with minor modifications to target  
X11) should be obvious. Also, I prefer to select the graphic window  
from a list. It is also possible to pass an argument to a script by  
bracketing it with  "on run argv ... end run" , where argv contains  
the passed parameter as a string, for example the output from  
dev.cur(), or dev.list(). As is, the script can be run directly from  
the Script menu or terminal without defining bringToTop() in R.

Atul

-- snip ----------------------------
-- save as ~/Library/Scripts/RScripts/RBringToTop.scpt")}

tell application "R"
	set winlist to (get name of windows) -- all windows including  
invisibles	
	set winlist2 to {} -- list of windows to present to user,  
specifically excludes invisibles in next line
	set winlist3 to {"Quartz", "R Console"}
	
	
	repeat with curWin in winlist
		if (winlist3 contains (curWin) or winlist3 contains (first word of  
curWin)) then
			set the end of winlist2 to curWin
		end if
	end repeat
	
	set actWin to (choose from list winlist2)
	
	
	
	if actWin is not false then
		tell application "System Events"
			tell process "R"
				click the menu item (first item of actWin) of the menu ¬
					"Window" of menu bar 1
			end tell
		end tell
	end if
end tell
-- snip ------------------------------
>
> Date: November 17, 2008 8:58:23 PM GMT-05:00
> To: <r-sig-mac@stat.math.ethz.ch>
> Subject: R base functions from R.app



I  am enormously grateful for the work and effort that has been put  
into the Mac port of R and R.app GUI.  However, there are a couple of  
functions I miss from other versions, and I was wondering if there is  
an easy way to add them.


2) bringToTop() would bring the active graphics window to the  
foreground, but seems to be missing from the Mac port. I've tried  
various ways of designating the active window etc, but none bring it  
to the foreground.



	[[alternative HTML version deleted]]



_______________________________________________
R-SIG-Mac mailing list
R-SIG-Mac@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-mac


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic