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: <[email protected]>
> 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
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to