Re: Refresh View After Mouse Inactivity
Re: Refresh View After Mouse Inactivity
- Subject: Re: Refresh View After Mouse Inactivity
- From: Richard Charles <email@hidden>
- Date: Tue, 03 May 2016 08:02:12 -0600
> On May 3, 2016, at 7:30 AM, Dave <email@hidden> wrote:
>
> How about sending it a Keystroke then?
I tried that several days ago and it did work!
void MySimulatedKeystroke(CGKeyCode virtualKey)
{
// Key down
CGEventRef e1 = CGEventCreateKeyboardEvent(NULL, virtualKey, true);
CGEventPost(kCGSessionEventTap, e1);
CFRelease(e1);
// Key up
CGEventRef e2 = CGEventCreateKeyboardEvent(NULL, virtualKey, false);
CGEventPost(kCGSessionEventTap, e2);
CFRelease(e2);
}
The problem was that the cursor can be in a text field with the text selected but the mouse elsewhere in the custom view. The custom view also responds to a lot of keyboard actions. So the problem was finding a keystroke which would be interpreted as a do nothing in the text field nor would ever do anything harmful or cause any side effects elsewhere. I tried a lot of different key strokes but could not find any that truly did nothing.
I also tried other types of benign events but they did not trigger the run loop. In my opinion this run loop has become a very stubborn thing. Prior to OS X 10.10 Yosemite you could do several things to cause the run loop to run once but not anymore.
I have not yet investigated NSActivityOptions as was suggested by Quincey but I have been rethinking my whole strategy and what I am trying to accomplish. For now I have moved in another direction which gives the user a little different type of feedback but may end up working well.
--Richard Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden