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: Sat, 30 Apr 2016 18:27:15 -0600
> On Apr 30, 2016, at 5:39 PM, Quincey Morris <email@hidden> wrote:
>
> Do you have any proof that ‘mouseMoved’ is called at all?
Yes adding logging shows that both methods mouseMoved: and mouseInactive are being called.
> Note that there are two different ‘mouseMoved’s. One is a continuous stream of events that come from via the window if “acceptsMouseMovedEvents” is YES. (It’s NO by default, and it’s a pretty bad idea to set it to YES, unless you enjoy avalanches.) The other is a stream of events that come from moving the mouse inside a NSTrackingArea, provided that the right initial conditions for detecting that the mouse is inside are satisfied. It’s not clear which technique you’re using here.
I am using NSTrackingArea.
> The other thing that occurs to me is that, following a recent discussion here about performSelector, you can’t validly pass @YES (an object) as a parameter to a method that expects a scalar value (a BOOL in this case). You’d need to wrap this in your own method that takes a NSNumber parameter, except that you’ve already sort of done that by providing this ‘mouseInactive’ method. (However, @YES would almost certainly produce a result of YES if mis-interpreted as a BOOL scalar, so that’s likely not the cause.)
I have tried this and get the same results.
NSNumber *yes = [NSNumber numberWithBool:YES];
[self performSelector:@selector(setNeedsDisplay:) withObject:yes afterDelay:0.0];
> Lastly, it’s always possible that something to do with power management is preventing events from being sent from the run loop. This is hard to figure out, because trying to debug it changes the scenario.
My programming notes say that calling performSelector:withObject:afterDelay: with a delay of 0.0 would cause the run loop run once but that stopped working with OS X 10.10 Yosemite (mid 2014 time frame).
I have tried all these crazy ways to get the run loop to run once but nothing works.
http://stackoverflow.com/questions/4739748/is-there-a-way-to-make-drawrect-work-right-now
It may be that the above stackoverflow discussion was pre Yosemite.
However if I press any key on the keyboard after mouse has stopped moving and the delay time period has passed then presto the view refreshes.
--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