jp-www@dcs.gla.ac.uk
2005-Dec-16 12:30 UTC
[Rd] AppleScript commands don't execute until mouse over console window (PR#8405)
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)];
Simon Urbanek
2005-Dec-16 19:30 UTC
[Rd] AppleScript commands don't execute until mouse over console window (PR#8405)
Thanks, Jonathan! I have now committed a slight variation of your patch in the current Mac-GUI. Cheers, Simon On Dec 16, 2005, at 7:30 AM, jp-www at dcs.gla.ac.uk wrote:> 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 to the 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.