From jp-www at dcs.gla.ac.uk  Fri Dec 16 13:30:41 2005
From: jp-www at dcs.gla.ac.uk (jp-www@dcs.gla.ac.uk)
Date: Fri, 16 Dec 2005 13:30:41 +0100 (CET)
Subject: [Rd] AppleScript commands don't execute until mouse over console
	window (PR#8405)
Message-ID: <20051216123041.2BB8D19A33@slim.kubism.ku.dk>

Full_Name: Jonathan Paisley
Version: 2.2.0
OS: Mac OS X 10.4.3
Submission from: (NULL) (81.178.69.159)


I am sending commands to R via AppleScript (specifically, from SubEthaEdit to
instruct it to source the file I'm currently editing). R doesn't respond tothe
AppleScript until I move the mouse over R's console window.

The following patch to the Mac GUI (against current svn trunk) resolves the
problem, by posting a dummy event to wake up the event queue after the command
has been stuffed into the input buffer.

--- RController.m	(revision 2076)
+++ RController.m	(working copy)
@@ -1104,7 +1104,18 @@
 The input replaces what the user is currently typing.
 */
 - (void) sendInput: (NSString*) text {
+	NSPoint null = {0,0};
 	[self consoleInput:text interactive:YES];
+    	[NSApp postEvent:[NSEvent otherEventWithType: NSApplicationDefined 
+                                            location: null
+                                       modifierFlags: 0 
+                                           timestamp: 0
+                                        windowNumber: 0
+                                             context: NULL
+                                             subtype: 0
+                                               data1: 0
+                                               data2: 0
+            ] atStart: YES]; 
 	/*
 	 unsigned textLength = [[RTextView textStorage] length];
 	 [RTextView setSelectedRange:NSMakeRange(textLength, 0)];



[Rd] AppleScript commands don't execute until mouse over console window (PR#8405)
jp-www@dcs.gla.ac.uk