Re: Cocoa really needs to be thread-safe
Re: Cocoa really needs to be thread-safe
- Subject: Re: Cocoa really needs to be thread-safe
- From: Ron Wilson <email@hidden>
- Date: Tue, 5 Nov 2002 09:00:29 -0800
On Tuesday, November 5, 2002, at 06:23 AM, Cameron Hayne
<email@hidden> wrote:
>
On 4/11/02 10:03 pm, "James DiPalma" <email@hidden> wrote:
>
> Once
>
> started my app happily updates once a second like a digital clock. If I
>
> depress a button, all time updates stop. If I begin a window resize,
>
> all time updates stop.
>
>
I suspect you need to use NSEventTrackingRunLoopMode when you register
>
the
>
timer. See my sample project "TestButtonDown" at:
>
http://hayne.net/MacDev/TestButtonDown/
>
which shows a counter quite happily incrementing even while a button is
>
held
>
down.
>
>
On 5/11/02 12:19 am, "Andy Lee" <email@hidden> wrote:
>
>> Many if not all of cocoa's widgets block (or simply wait for
>
>> nextEventMatchingMask:) to return a mouse-up event during mouse
>
>> down. I'm surprised anyone actually noticed.
>
>
>
> This is one of the *first* things I noticed about OS X. I think I
>
> first noticed it with a scroll bar while multiple browser windows
>
> were busy drawing themselves. The windows would stop drawing while I
>
> had the mouse down. I was pretty embarrassed by this, since I had
>
> assumed OS X's UI would be at least as smoothly multithreaded as
>
> Windows. It looked like widgets were handling mouse-downs inside a
>
> blocking loop, which is *so* OS 9.
>
>
I don't think that behaviour is the fault of the Cocoa widgets. It seems
>
more likely to have been the fault of the application programmer.
Being curious, I tried looking up NSEventTrackingRunLoopMode in the
Apple Cocoa docs, AppKiDo, Cocoa Browser and MTLibrarian. Not much
there. Nothing on Stepwise or Cocoa Dev Central. Google got me to
cocoa.mamasam.com, where someone had asked a different question and had
gotten somewhat the same answer as above (to use
NSEventTrackingRunLoopMode), and also that this still did nothing to
correct the problem during window resizing - NSWindow apparently uses
it's own event loop and does not honor NSEventTrackingRunLoopMode. The
docs for NSRunLoop say of NSEventTrackingRunLoopMode: "Use this mode for
event tracking loops".
So, although the exact problem expressed by the OP may be due to an
oversight in not adding the timer to the the run loops button tracking
mode, it sure looks like poor documentation contributed to the confusion.
Maybe one of you old pros could write an article about NSRunLoop and run
loop modes and put in on mamasam, dev central or stepwise?
--Ron
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.