Re: Layout-triggered animation

2014-04-23 Thread Jakob Egger

> New questions:
> 1. Is there any point in using addConstraint/removeConstraint in the 
> NSAnimationContext grouping? Seems like it can go before beginGrouping.

The important thing is that the frames are set inside the grouping. Updating 
constraints should not cause any frames to be set, only the layoutIfNeeded 
method should perform layout.

> 2. As you can see in the code, I check to see if the implicit animation 
> setting is there at runtime (added in 10.8). AFAICT there is no simple way to 
> do the animation in 10.7 when the autolayout was added. Apple had an 
> oversight in 10.7 and fixed it in 10.8?

Hm. NSLayoutConstraint conforms to NSAnimatablePropertyContainer, so you could 
perform an animation by animating the constant, eg. [[collapseConstraint 
animator] setConstant: 20]. However I don't know for sure if this works on 
10.7, it doesn't say in the docs.

> 3. The jitter problem. It's even more severe when the animation duration is 
> shorter. I'm using 0.6 as the production duration.
> 4. (for good measure) Also, watch the focus ring while these animations are 
> happening. I don't know if this is a Cocoa issue, or another symptom of my 
> problematic code. The NSButton has the focus, but that view's frame is 
> definitely not changing as a result of layout, as you can see.

I believe that the reason for the jitter is that frames are set multiple times, 
but I doubt there is anything you can do about it. You could set a breakpoint 
on setFrame: to try to debug, but I'm not sure that's worthwhile.


A different way to approach your problem would be to use a (view-based) 
NSTableView or an NSOutlineView. Animations in table views are much easier to 
get right in my experience.

Best wishes,
Jakob
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Memory Leaks and ARC

2014-04-23 Thread Dave

On 23 Apr 2014, at 00:18, Quincey Morris  
wrote:

> On Apr 22, 2014, at 15:18 , Dave  wrote:
> 
>> I assumed that ARC would release myImage on each interation of the loop, 
>> however, this seems not to be the case
> 
> The ‘myImage’ variable gives up *ownership* of the previous image object when 
> you create a new one in the loop, but whether that leads to a deallocation of 
> the object is an implementation detail. If it’s autoreleased anywhere in its 
> [short] lifetime, the image object will linger in the autorelease pool until 
> the pool is drained, as Keary said.
> 
> If you want to avoid autoreleases, you should ensure that the image is 
> returned from the download method with +1 ownership semantics. As far as that 
> method is concerned, you can do this by changing its name to start with 
> ‘new…’, or decorate its declaration with 
> ‘__attribute__((ns_returns_retained))’. You would, of course, have to ensure 
> that the download method and the methods it calls don’t do anything else 
> that’s likely to retain/autorelease the image.
> 

A, I didn’t realize that ARC follows the same rules, e.g. new, alloc, in 
method names. 

The flow of control goes as follows:

test  calls:
self commandDownloadImageWithFileURLString calls:
self.pServerAPI newDownloadImageFileWithURL: < 
Already returns a +1 “owned” Object
 
> This sort of thing is a bit messy because it relies on presumed (but 
> partially documented) knowledge of the ARC implementation. It’s more robust 
> and straightforward to do what Keary says. However, if you really wanted to 
> avoid autoreleases completely, there are ARC strategies that can help.
> 

If I changed the names of commandDownloadImageWithFileURLString to be 
newCommandDownloadImageWithFileURLString, this would cause it to release 
myImage on each iteration rather than using Autorelease? 

Is there anyway of telling if an Object is in “autorelease” state? I mean just 
for testing, I wouldn’t rely on this in shipping code.

I’d rather avoid autorelease if possible, it has only ever caused me grief in 
the long run!

Cheers
Dave




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

showing load progress for autosaved documents

2014-04-23 Thread edward m taffel
i’m attempting to show load progress for complex documents. my document class 
defines readFromURL & this seems the natural place to do this; however, for 
autosaved documents the progress window does not show until the document window 
shows (in the same instant, after the load is complete). i expect this is 
something to do w/ readFromURL being sent from a background thread; but, there 
must certainly be some way to flush the progress window. 

all/any suggestions greatly appreciated.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Mouse cursors and overlapping sibling NSViews

2014-04-23 Thread Sean McBride
Hi all,

I'm trying to determine how to manage the mouse cursor in the case of 
overlapping sibling views.

I have a custom NSView that needs to change its cursor depending on mouse 
position and internal state.  The sibling views (which all draw on top of my 
view, thus appearing sorta like subviews) are simple standard Cocoa controls 
(ex: push buttons, popup menus).  Since those siblings views are always 'on 
top', I want them to decide the mouse cursor if the cursor is above them, but 
Cocoa still calls my mouseMoved: method, which I guess is not unreasonable 
since the cursor is in fact above several views at the same time.

I haven't been able to find any docs about how cursor handling works with 
overlapping views, anyone know?

Thanks,

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mouse cursors and overlapping sibling NSViews

2014-04-23 Thread Ken Thomases
On Apr 23, 2014, at 8:48 AM, Sean McBride wrote:

> I'm trying to determine how to manage the mouse cursor in the case of 
> overlapping sibling views.
> 
> I have a custom NSView that needs to change its cursor depending on mouse 
> position and internal state.  The sibling views (which all draw on top of my 
> view, thus appearing sorta like subviews) are simple standard Cocoa controls 
> (ex: push buttons, popup menus).  Since those siblings views are always 'on 
> top', I want them to decide the mouse cursor if the cursor is above them, but 
> Cocoa still calls my mouseMoved: method, which I guess is not unreasonable 
> since the cursor is in fact above several views at the same time.
> 
> I haven't been able to find any docs about how cursor handling works with 
> overlapping views, anyone know?

I don't know of any docs.  I suspect the superview iterates through its 
subviews in the order they appear in the array returned by the -subviews 
method, calling -hitTest: on each until one returns a hit (i.e. non-nil).  So, 
you might try overriding -hitTest: for the superview and implementing the logic 
you prefer.

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mouse cursors and overlapping sibling NSViews

2014-04-23 Thread Sean McBride
On Wed, 23 Apr 2014 08:58:49 -0500, Ken Thomases said:

>> I have a custom NSView that needs to change its cursor depending on
>mouse position and internal state.  The sibling views (which all draw on
>top of my view, thus appearing sorta like subviews) are simple standard
>Cocoa controls (ex: push buttons, popup menus).  Since those siblings
>views are always 'on top', I want them to decide the mouse cursor if the
>cursor is above them, but Cocoa still calls my mouseMoved: method, which
>I guess is not unreasonable since the cursor is in fact above several
>views at the same time.
>> 
>> I haven't been able to find any docs about how cursor handling works
>with overlapping views, anyone know?
>
>I don't know of any docs.  I suspect the superview iterates through its
>subviews in the order they appear in the array returned by the -subviews
>method, calling -hitTest: on each until one returns a hit (i.e. non-
>nil).

Probably you're right, it certainly seems to use that order when drawing.

Is hitTest: used for cursors as well as clicks?  I put a breakpoint to test the 
theory, and indeed I see in a backtrace [NSWindow(NSCarbonExtensions) 
_setCursorForMouseLocation:]

>So, you might try overriding -hitTest: for the superview and
>implementing the logic you prefer.

How would I distinguish being in hitTest: because of a mouse click vs because 
of a cursor set?  Check the current event type?

Cheers,

-- 

Sean McBride, B. Eng s...@rogue-research.com
Rogue Researchwww.rogue-research.com 
Mac Software Developer  Montréal, Québec, Canada



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mouse cursors and overlapping sibling NSViews

2014-04-23 Thread edward taffel
if i understand you correctly: you want to adjust the cursor in your view based 
on state, but embedded controls should set the cursor independently. you might 
try subclassing the controls in question, register a tracking area (for 
controls that do not already have one, only) & define mouseEntered (set the 
cursor here) for each. i’ve done similar w/ custom views but your results may 
vary w/ stock controls.

hope this helps.


On Apr 23, 2014, at 9:48 AM, Sean McBride  wrote:

> Hi all,
> 
> I'm trying to determine how to manage the mouse cursor in the case of 
> overlapping sibling views.
> 
> I have a custom NSView that needs to change its cursor depending on mouse 
> position and internal state.  The sibling views (which all draw on top of my 
> view, thus appearing sorta like subviews) are simple standard Cocoa controls 
> (ex: push buttons, popup menus).  Since those siblings views are always 'on 
> top', I want them to decide the mouse cursor if the cursor is above them, but 
> Cocoa still calls my mouseMoved: method, which I guess is not unreasonable 
> since the cursor is in fact above several views at the same time.
> 
> I haven't been able to find any docs about how cursor handling works with 
> overlapping views, anyone know?
> 
> Thanks,
> 
> -- 
> 
> Sean McBride, B. Eng s...@rogue-research.com
> Rogue Researchwww.rogue-research.com 
> Mac Software Developer  Montréal, Québec, Canada
> 
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/etaffel%40me.com
> 
> This email sent to etaf...@me.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Memory Leaks and ARC

2014-04-23 Thread Quincey Morris
On Apr 23, 2014, at 03:01 , Dave  wrote:

> If I changed the names of commandDownloadImageWithFileURLString to be 
> newCommandDownloadImageWithFileURLString, this would cause it to release 
> myImage on each iteration rather than using Autorelease? 

It would remove one — and perhaps the only — reason for ARC to use autorelease, 
but there’s no way of knowing whether there are others, hidden from you. For 
example, even if you create a new image using some alloc/init that returns the 
created object with +1 ownership, it may have already been autoreleased before 
it gets back to you.

The outcome is also going to vary with the version of clang you compiled with, 
and the OS version you’re running on. The current clang already uses 
autorelease less often than the original implementation, and Cocoa classes may 
get converted from MRR to ARC gradually over OS releases.

It seems to me that the best practice is:

— Return objects with +1 ownership when semantically appropriate (when the 
caller gets an object that is conceptually new).

— Investigate memory usage with Instruments, preferably on supported older OS 
versions too.

— Bracket problem areas with @autoreleasepool{} only you’ve identified a 
problem area with Instruments.

— Don't gratuitously insert @autoreleasepool{} in loops “just for safety”.

> Is there anyway of telling if an Object is in “autorelease” state? I mean 
> just for testing, I wouldn’t rely on this in shipping code.

I don’t think so.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mouse cursors and overlapping sibling NSViews

2014-04-23 Thread edward taffel
erratum: in your context, initializing tracking w/ NSTrackingCursorUpdate & 
defining cursorUpdate is probably more appropriate.
&, on further reflection, this technique does not inhibit the sending of 
mouseMoved in the parent view.
an interesting problem—should you discover a solution i hope you will post it.

On Apr 23, 2014, at 1:16 PM, edward taffel  wrote:

> if i understand you correctly: you want to adjust the cursor in your view 
> based on state, but embedded controls should set the cursor independently. 
> you might try subclassing the controls in question, register a tracking area 
> (for controls that do not already have one, only) & define mouseEntered (set 
> the cursor here) for each. i’ve done similar w/ custom views but your results 
> may vary w/ stock controls.
> 
> hope this helps.
> 
> 
> On Apr 23, 2014, at 9:48 AM, Sean McBride  wrote:
> 
>> Hi all,
>> 
>> I'm trying to determine how to manage the mouse cursor in the case of 
>> overlapping sibling views.
>> 
>> I have a custom NSView that needs to change its cursor depending on mouse 
>> position and internal state.  The sibling views (which all draw on top of my 
>> view, thus appearing sorta like subviews) are simple standard Cocoa controls 
>> (ex: push buttons, popup menus).  Since those siblings views are always 'on 
>> top', I want them to decide the mouse cursor if the cursor is above them, 
>> but Cocoa still calls my mouseMoved: method, which I guess is not 
>> unreasonable since the cursor is in fact above several views at the same 
>> time.
>> 
>> I haven't been able to find any docs about how cursor handling works with 
>> overlapping views, anyone know?
>> 
>> Thanks,
>> 
>> -- 
>> 
>> Sean McBride, B. Eng s...@rogue-research.com
>> Rogue Researchwww.rogue-research.com 
>> Mac Software Developer  Montréal, Québec, Canada
>> 
>> 
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/etaffel%40me.com
>> 
>> This email sent to etaf...@me.com
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/etaffel%40me.com
> 
> This email sent to etaf...@me.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Memory Leaks and ARC

2014-04-23 Thread Dave
Hi,

Yes, I realize that. But in this case, the root object obeys the new/alloc 
rule. it’s complicated because this App is a meld of 3 apps all developed at 
varying times.

In this case, there was an old-school network manager, that used manual MM. 
This was kept like that (by switching off ARC on a file-by-file basis) and a 
layer on top added like so:


Old-School Manual MM obeys new/alloc
NewLayer ARC - doesn’t not obey new/alloc.

The NewLayer is shallow and would be easy to change the names, then everything 
from the network layer should be NOT be auto-released.

I was thinking, what would be very useful is if the Static Analyzer would run 
the rules as if it were NON-Arc, that way it would generate a warning when the 
Chain was broken and an object was made auto-releasible.

Thanks for your help, I’m going to change the names and see if it makes a 
difference.

Cheers
Dave


On 23 Apr 2014, at 18:26, Quincey Morris  
wrote:

> On Apr 23, 2014, at 03:01 , Dave  wrote:
> 
>> If I changed the names of commandDownloadImageWithFileURLString to be 
>> newCommandDownloadImageWithFileURLString, this would cause it to release 
>> myImage on each iteration rather than using Autorelease? 
> 
> It would remove one — and perhaps the only — reason for ARC to use 
> autorelease, but there’s no way of knowing whether there are others, hidden 
> from you. For example, even if you create a new image using some alloc/init 
> that returns the created object with +1 ownership, it may have already been 
> autoreleased before it gets back to you.
> 
> The outcome is also going to vary with the version of clang you compiled 
> with, and the OS version you’re running on. The current clang already uses 
> autorelease less often than the original implementation, and Cocoa classes 
> may get converted from MRR to ARC gradually over OS releases.
> 
> It seems to me that the best practice is:
> 
> — Return objects with +1 ownership when semantically appropriate (when the 
> caller gets an object that is conceptually new).
> 
> — Investigate memory usage with Instruments, preferably on supported older OS 
> versions too.
> 
> — Bracket problem areas with @autoreleasepool{} only you’ve identified a 
> problem area with Instruments.
> 
> — Don't gratuitously insert @autoreleasepool{} in loops “just for safety”.
> 
>> Is there anyway of telling if an Object is in “autorelease” state? I mean 
>> just for testing, I wouldn’t rely on this in shipping code.
> 
> I don’t think so.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSToolbarItem view set to NSButton view, but not showing...

2014-04-23 Thread Peters, Brandon
Devs,

I have a custom NSToolbarItem with a NSButton underneath. I set the main and 
alternate images for the button using [NSImage imageNamed:imageName], then call 
[toolbaritem setView:view] and pass in the NSButton. But when I run the 
application, the NSToolbarItem is does not show the image and the look of the 
toolbar item is the default from IB. The image is of type .icns, with various 
representations based on Apple’s guidelines.

Any suggestions on how to find the problem would be much appreciated.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

NSToolbarItem view set to NSButton, but not images showing...

2014-04-23 Thread Peters, Brandon
I have a custom NSToolbarItem with a NSButton underneath. I set the main and 
alternate images for the button using [NSImage imageNamed:imageName], then call 
[toolbaritem setView:view] and pass in the NSButton. But when I run the 
application, the NSToolbarItem is does not show the image and the look of the 
toolbar item is the default from IB. The image is of type .icns, with various 
representations based on Apple’s guidelines.

Any suggestions on how to find the problem would be much appreciated.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbarItem view set to NSButton view, but not showing...

2014-04-23 Thread Jerry Krinock

On 2014 Apr 23, at 15:13, Peters, Brandon  wrote:

> call [toolbaritem setView:view] and pass in the NSButton.

Try some bonehead debugging with NSLog().  Verify that toolbaritem is your 
target item at that point, in particular, that it is not nil. If that seems to 
be OK, try some more advanced debugging, later, and see if toolbaritem is still 
alive, and if so what is its view.

Also, NSToolbar/Item are kind of crazy cats and customizing them is often found 
to be problematic.  If possible, use the default NSToolbarItem and -setImage:.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: showing load progress for autosaved documents

2014-04-23 Thread Graham Cox

On 23 Apr 2014, at 10:31 pm, edward m taffel  wrote:

> i’m attempting to show load progress for complex documents. my document class 
> defines readFromURL & this seems the natural place to do this; however, for 
> autosaved documents the progress window does not show until the document 
> window shows (in the same instant, after the load is complete). i expect this 
> is something to do w/ readFromURL being sent from a background thread; but, 
> there must certainly be some way to flush the progress window. 
> 
> all/any suggestions greatly appreciated.

I recently (re)implemented a comprehensive progress-reporting interface in my 
app, and it is able to hook into document read/writes.

The important thing I learned was NOT to attempt to "drive" the progress 
indication from the worker code (i.e. the code that's doing the actual work - 
file I/O for example, or archiving/dearchiving). Instead, get the progress UI 
to poll for progress on the work that it's interested in from the main thread. 
This flips the situation on its head, but it works out beautifully (the idea 
came from Jens Alfke). The progress UI just sits on the main thread, updating 
naturally, and it periodically asks the work how far it has got, using a simple 
timer. You need a protocol or other API that the worker code can adopt so that 
it is pollable by progress, and a way to set up and tear down the progress at 
the start and end of the work itself. In my case I can show any number of 
simultaneous progress views within a stack, since multiple work units can be 
done on different threads, so I also need a way to associate the work with the 
given progress controller. In my case this is trivially a reference to the 
object that implements the progress-pollable protocol.

Note that in 10.9 there is also a 'NSProgress' object that defines an API for 
progress-monitorable work, though don't be misled into thinking this provides 
any sort of UI - it doesn't. But adopting it rather than rolling your own might 
be an idea, though in my case I didn't because I need to support back to 10.6.

So for the case of saving a document, which in my case involves using 
NSKeyedArchiver to archive an object graph, I assign a delegate to the archiver 
which keeps track of how many objects it has archived out of the total number 
it will archive (figuring that out in advance was the hardest part, but it 
doesn't need to be more precise than a rough estimate for reasonable progress 
accuracy). The delegate starts a progress on the first call and stops it on the 
last, and then the progress polls it at intervals displaying the result. A 
simple 'atomic' property is all I need to read the amount of work value in a 
thread-safe manner.

--Graham



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbarItem view set to NSButton view, but not showing...

2014-04-23 Thread Eric Shepherd
There's a lot to be said for spreading lots of NSLog through your code. It's 
amazing how many bugs you can nail down using this old-school form of debugging.

Eric Shepherd

> On Apr 23, 2014, at 6:36 PM, Jerry Krinock  wrote:
> 
> Try some bonehead debugging with NSLog().  Verify that toolbaritem is your 
> target item at that point, in particular, that it is not nil. If that seems 
> to be OK, try some more advanced debugging, later, and see if toolbaritem is 
> still alive, and if so what is its view.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mouse cursors and overlapping sibling NSViews

2014-04-23 Thread Ken Thomases
On Apr 23, 2014, at 9:39 AM, Sean McBride wrote:

> Is hitTest: used for cursors as well as clicks?  I put a breakpoint to test 
> the theory, and indeed I see in a backtrace [NSWindow(NSCarbonExtensions) 
> _setCursorForMouseLocation:]

-hitTest: should be used for anything which needs to determine which view a 
mouse location is associated with.


>> So, you might try overriding -hitTest: for the superview and
>> implementing the logic you prefer.
> 
> How would I distinguish being in hitTest: because of a mouse click vs because 
> of a cursor set?  Check the current event type?

Why do you want to distinguish that?  If the cursor is appropriate for a given 
view, that's a *strong* indication to the user that a click will act on that 
view.  So, the view controlling the cursor at a given point should also be the 
view that receives the click at that point.

Another thing you can try, depending on what's actually in the sibling views, 
is to have the superview take over all mouse events.  Have its -hitTest: return 
itself or nil, never a subview (even indirectly by invoking -hitTest: on its 
subviews or super).  Then it controls both the cursor and the response to 
clicks.

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbarItem view set to NSButton view, but not showing...

2014-04-23 Thread Andy Lee

On Apr 23, 2014, at 6:36 PM, Jerry Krinock  wrote:

> 
> On 2014 Apr 23, at 15:13, Peters, Brandon  wrote:
> 
>> call [toolbaritem setView:view] and pass in the NSButton.
> 
> Try some bonehead debugging with NSLog().  Verify that toolbaritem is your 
> target item at that point, in particular, that it is not nil.

Two more things you can easily check:

* [NSImage imageNamed:imageName] is not returning nil.
* What is your button's imagePosition?  If it's NSNoImage that might explain it.

--Andy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbarItem view set to NSButton view, but not showing...

2014-04-23 Thread Peters, Brandon
Jerry,

The example I was following comes from Stack Overflow and going something like 
this within the custom toolbar item:

NSButton *button = [[NSButton alloc]init];
[button setImage:[NSImage imageNamed:@"StarEmpty"]];
[button setAlternateImage:[NSImage imageNamed:@"StarFull"]];
[button setImagePosition:NSImageOnly];
[button setBordered:NO];

[self.toolbarItem setView:button];

At any rate, I tried your suggestion and I still got nothing. I will continue 
to hammer at it, but if not I will just get rid of the toolbar roll some custom 
NSButtons. Thanks.

On Apr 23, 2014, at 6:36 PM, Jerry Krinock 
mailto:je...@ieee.org>> wrote:


On 2014 Apr 23, at 15:13, Peters, Brandon 
mailto:bap...@my.fsu.edu>> wrote:

call [toolbaritem setView:view] and pass in the NSButton.

Try some bonehead debugging with NSLog().  Verify that toolbaritem is your 
target item at that point, in particular, that it is not nil. If that seems to 
be OK, try some more advanced debugging, later, and see if toolbaritem is still 
alive, and if so what is its view.

Also, NSToolbar/Item are kind of crazy cats and customizing them is often found 
to be problematic.  If possible, use the default NSToolbarItem and -setImage:.


___

Cocoa-dev mailing list 
(Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/bap04e%40my.fsu.edu

This email sent to bap...@my.fsu.edu

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: showing load progress for autosaved documents

2014-04-23 Thread edward taffel
thank you for this graham!

at present, i’m finding it difficult to find a point, prior to NSDocument 
initializing autosaved documents, to show a progress window. everything above 
readFromURL is off the main thread & there is nothing in the application 
delegate protocol that precedes—so far as i’m aware. any thoughts here?

best,
edward


On Apr 23, 2014, at 7:36 PM, Graham Cox  wrote:

> 
> On 23 Apr 2014, at 10:31 pm, edward m taffel  wrote:
> 
>> i’m attempting to show load progress for complex documents. my document 
>> class defines readFromURL & this seems the natural place to do this; 
>> however, for autosaved documents the progress window does not show until the 
>> document window shows (in the same instant, after the load is complete). i 
>> expect this is something to do w/ readFromURL being sent from a background 
>> thread; but, there must certainly be some way to flush the progress window. 
>> 
>> all/any suggestions greatly appreciated.
> 
> I recently (re)implemented a comprehensive progress-reporting interface in my 
> app, and it is able to hook into document read/writes.
> 
> The important thing I learned was NOT to attempt to "drive" the progress 
> indication from the worker code (i.e. the code that's doing the actual work - 
> file I/O for example, or archiving/dearchiving). Instead, get the progress UI 
> to poll for progress on the work that it's interested in from the main 
> thread. This flips the situation on its head, but it works out beautifully 
> (the idea came from Jens Alfke). The progress UI just sits on the main 
> thread, updating naturally, and it periodically asks the work how far it has 
> got, using a simple timer. You need a protocol or other API that the worker 
> code can adopt so that it is pollable by progress, and a way to set up and 
> tear down the progress at the start and end of the work itself. In my case I 
> can show any number of simultaneous progress views within a stack, since 
> multiple work units can be done on different threads, so I also need a way to 
> associate the work with the given progress controller. In my case this is 
> trivially a reference to the object that implements the progress-pollable 
> protocol.
> 
> Note that in 10.9 there is also a 'NSProgress' object that defines an API for 
> progress-monitorable work, though don't be misled into thinking this provides 
> any sort of UI - it doesn't. But adopting it rather than rolling your own 
> might be an idea, though in my case I didn't because I need to support back 
> to 10.6.
> 
> So for the case of saving a document, which in my case involves using 
> NSKeyedArchiver to archive an object graph, I assign a delegate to the 
> archiver which keeps track of how many objects it has archived out of the 
> total number it will archive (figuring that out in advance was the hardest 
> part, but it doesn't need to be more precise than a rough estimate for 
> reasonable progress accuracy). The delegate starts a progress on the first 
> call and stops it on the last, and then the progress polls it at intervals 
> displaying the result. A simple 'atomic' property is all I need to read the 
> amount of work value in a thread-safe manner.
> 
> --Graham
> 
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: showing load progress for autosaved documents

2014-04-23 Thread Graham Cox

On 24 Apr 2014, at 10:06 am, edward taffel  wrote:

> at present, i’m finding it difficult to find a point, prior to NSDocument 
> initializing autosaved documents, to show a progress window. everything above 
> readFromURL is off the main thread & there is nothing in the application 
> delegate protocol that precedes—so far as i’m aware. any thoughts here?
> 


Design your progress stuff so that it can be initiated from any thread. It's 
not a big problem - I use -performSelectorOnMainThread: etc. Then you can 
insert code to establish progress anywhere that's convenient - usually at the 
start of the work itself.

--Graham



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbarItem view set to NSButton view, but not showing...

2014-04-23 Thread Peters, Brandon
Andy,

I inserted code to check for nil images and image position, here is what I got:
// set the original and alternate images...names are “opposite"
NSImage *image = [NSImage imageNamed:@"StopButtonAlternateIcon”];
if(image)
{
NSLog(@"Setting 1st image for stop button");
[_button setImage:image];
}
else
{
NSLog(@"Image is null for StopButtonAlternateIcon");
}



image = [NSImage imageNamed:@"StopButtonIcon"];
if(image)
{
NSLog(@"Setting 2nd image for stop button");
[_button setAlternateImage:image];
}
else
{
NSLog(@"Image is null for StopButtonIcon");
}



// image position

[_button setImagePosition:NSImageOnly];
NSLog(@"Image position: %lu", [_button imagePosition]);


From the console:
2014-04-23 20:41:18.394 3D Rolling Ball Simulator[6321:303] Setting 1st image 
for stop button
2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Setting 2nd image 
for stop button
2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Image position: 1

On Apr 23, 2014, at 7:59 PM, Andy Lee mailto:ag...@mac.com>> 
wrote:


On Apr 23, 2014, at 6:36 PM, Jerry Krinock 
mailto:je...@ieee.org>> wrote:


On 2014 Apr 23, at 15:13, Peters, Brandon 
mailto:bap...@my.fsu.edu>> wrote:

call [toolbaritem setView:view] and pass in the NSButton.

Try some bonehead debugging with NSLog().  Verify that toolbaritem is your 
target item at that point, in particular, that it is not nil.

Two more things you can easily check:

* [NSImage imageNamed:imageName] is not returning nil.
* What is your button's imagePosition?  If it's NSNoImage that might explain it.

--Andy

___

Cocoa-dev mailing list 
(Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/bap04e%40my.fsu.edu

This email sent to bap...@my.fsu.edu

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mouse cursors and overlapping sibling NSViews

2014-04-23 Thread Quincey Morris
On Apr 23, 2014, at 16:58 , Ken Thomases  wrote:

> If the cursor is appropriate for a given view, that's a *strong* indication 
> to the user that a click will act on that view.  So, the view controlling the 
> cursor at a given point should also be the view that receives the click at 
> that point.

Wait, did I miss something? Wasn’t Edward correct in pointing out that using 
mouseMoved: to set the cursor is not correct, and cursorUpdate: should be used 
instead (with tracking areas with NSTrackingCursorUpdate) should be used. That 
mechanism already chooses the correct view to get set the cursor.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbarItem view set to NSButton view, but not showing...

2014-04-23 Thread Andy Lee
Oh well, it was worth a try, and at least you've confirmed some basic steps 
*are* working.

From your previous message it sounds like you also checked self.toolbarItem and 
it too was not nil (as it could have been if, for example, you'd forgotten to 
connect an outlet in IB -- or if you were trying to plug in the button during 
init, which is too early).

If I understand what Jerry was getting at, you might want to log the addresses 
of the toolbar item and the button, and at some later point in the program 
confirm everything's still where you think it is.  For example, you could put a 
breakpoint in the toolbar item's action method and look at sender.  (I *think* 
that makes sense, but it might not; I haven't made a toolbar in long time.)

As a really trivial sanity check, maybe instead of setting the image, you could 
set the title.  If you still have the problem, at least you know it's not 
related to setting the image.

--Andy

On Apr 23, 2014, at 8:47 PM, "Peters, Brandon"  wrote:

> Andy,
> 
> I inserted code to check for nil images and image position, here is what I 
> got:
> // set the original and alternate images...names are “opposite"
> NSImage *image = [NSImage imageNamed:@"StopButtonAlternateIcon”];
> if(image)
> {
> NSLog(@"Setting 1st image for stop button");
> [_button setImage:image];
> }
> else
> {
> NSLog(@"Image is null for StopButtonAlternateIcon");
> }
> 
> image = [NSImage imageNamed:@"StopButtonIcon"];
> if(image)
> {
> NSLog(@"Setting 2nd image for stop button");
> [_button setAlternateImage:image];
> }
> else
> {
> NSLog(@"Image is null for StopButtonIcon");
> }
> 
> // image position
> [_button setImagePosition:NSImageOnly];
> NSLog(@"Image position: %lu", [_button imagePosition]);
> 
> 
> From the console:
> 2014-04-23 20:41:18.394 3D Rolling Ball Simulator[6321:303] Setting 1st image 
> for stop button
> 2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Setting 2nd image 
> for stop button
> 2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Image position: 1
> 
> On Apr 23, 2014, at 7:59 PM, Andy Lee  wrote:
> 
>> 
>> On Apr 23, 2014, at 6:36 PM, Jerry Krinock  wrote:
>> 
>>> 
>>> On 2014 Apr 23, at 15:13, Peters, Brandon  wrote:
>>> 
 call [toolbaritem setView:view] and pass in the NSButton.
>>> 
>>> Try some bonehead debugging with NSLog().  Verify that toolbaritem is your 
>>> target item at that point, in particular, that it is not nil.
>> 
>> Two more things you can easily check:
>> 
>> * [NSImage imageNamed:imageName] is not returning nil.
>> * What is your button's imagePosition?  If it's NSNoImage that might explain 
>> it.
>> 
>> --Andy
>> 
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/bap04e%40my.fsu.edu
>> 
>> This email sent to bap...@my.fsu.edu
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Mouse cursors and overlapping sibling NSViews

2014-04-23 Thread Ken Thomases
On Apr 23, 2014, at 7:57 PM, Quincey Morris wrote:

> On Apr 23, 2014, at 16:58 , Ken Thomases  wrote:
> 
>> If the cursor is appropriate for a given view, that's a *strong* indication 
>> to the user that a click will act on that view.  So, the view controlling 
>> the cursor at a given point should also be the view that receives the click 
>> at that point.
> 
> Wait, did I miss something? Wasn’t Edward correct in pointing out that using 
> mouseMoved: to set the cursor is not correct, and cursorUpdate: should be 
> used instead (with tracking areas with NSTrackingCursorUpdate) should be 
> used. That mechanism already chooses the correct view to get set the cursor.

I didn't see anybody saying that the cursor was being set in -mouseMoved:.  As 
far as I understood the original issue, it's that the cursor is set via 
tracking areas and -cursorUpdate: on one view but -mouseMoved: is being called 
on a different view.  Sean wants Cocoa to be consistent about which view is 
asked to update the cursor and which is told that the mouse has moved.

But I may have misunderstood.

(Of course, the better solution, is seems to me, is to stop using sibling views 
in a situation that calls for subviews.)

Regards,
Ken


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbarItem view set to NSButton view, but not showing...

2014-04-23 Thread Peters, Brandon
Andy,

I discovered something that may lead to the real culprit. Using the debugger, I 
checked the size of the image chosen by imageNamed method, it was choosing the 
128x128 icon image, but my toolbar item buttons were 48x48. I changed the 
toolbar item sizes to 32x32, same thing.

On Apr 23, 2014, at 9:12 PM, Andy Lee mailto:ag...@mac.com>> 
wrote:

Oh well, it was worth a try, and at least you've confirmed some basic steps 
*are* working.

From your previous message it sounds like you also checked self.toolbarItem and 
it too was not nil (as it could have been if, for example, you'd forgotten to 
connect an outlet in IB -- or if you were trying to plug in the button during 
init, which is too early).

If I understand what Jerry was getting at, you might want to log the addresses 
of the toolbar item and the button, and at some later point in the program 
confirm everything's still where you think it is.  For example, you could put a 
breakpoint in the toolbar item's action method and look at sender.  (I *think* 
that makes sense, but it might not; I haven't made a toolbar in long time.)

As a really trivial sanity check, maybe instead of setting the image, you could 
set the title.  If you still have the problem, at least you know it's not 
related to setting the image.

--Andy

On Apr 23, 2014, at 8:47 PM, "Peters, Brandon" 
mailto:bap...@my.fsu.edu>> wrote:

Andy,

I inserted code to check for nil images and image position, here is what I got:
// set the original and alternate images...names are “opposite"
NSImage *image = [NSImage imageNamed:@"StopButtonAlternateIcon”];
if(image)
{
NSLog(@"Setting 1st image for stop button");
[_button setImage:image];
}
else
{
NSLog(@"Image is null for StopButtonAlternateIcon");
}

image = [NSImage imageNamed:@"StopButtonIcon"];
if(image)
{
NSLog(@"Setting 2nd image for stop button");
[_button setAlternateImage:image];
}
else
{
NSLog(@"Image is null for StopButtonIcon");
}

// image position
[_button setImagePosition:NSImageOnly];
NSLog(@"Image position: %lu", [_button imagePosition]);


From the console:
2014-04-23 20:41:18.394 3D Rolling Ball Simulator[6321:303] Setting 1st image 
for stop button
2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Setting 2nd image 
for stop button
2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Image position: 1

On Apr 23, 2014, at 7:59 PM, Andy Lee mailto:ag...@mac.com>> 
wrote:


On Apr 23, 2014, at 6:36 PM, Jerry Krinock 
mailto:je...@ieee.org>> wrote:


On 2014 Apr 23, at 15:13, Peters, Brandon 
mailto:bap...@my.fsu.edu>> wrote:

call [toolbaritem setView:view] and pass in the NSButton.

Try some bonehead debugging with NSLog().  Verify that toolbaritem is your 
target item at that point, in particular, that it is not nil.

Two more things you can easily check:

* [NSImage imageNamed:imageName] is not returning nil.
* What is your button's imagePosition?  If it's NSNoImage that might explain it.

--Andy

___

Cocoa-dev mailing list 
(Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/bap04e%40my.fsu.edu

This email sent to bap...@my.fsu.edu



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Layout-triggered animation

2014-04-23 Thread Julian
Based on your thought about setFrame: called multiple times, I do have some
interesting news, though not a full resolution: setFrameSize was getting
called repeatedly with the final size during the animation. I put logging
in setFrame{Size,Origin}: in the view whose constraints are altered. Here's
what it looks like during an expand:

2014-04-23 14:44:45.189 Pasteboard Inspector[1616:303] Setting frame
origin: {0, 91}
2014-04-23 14:44:45.190 Pasteboard Inspector[1616:303] Setting frame size:
{600, 352} XXX
2014-04-23 14:44:45.261 Pasteboard Inspector[1616:303] Setting frame size:
{600, 43}
2014-04-23 14:44:45.277 Pasteboard Inspector[1616:303] Setting frame size:
{600, 45}
. cut to the middle...
2014-04-23 14:44:47.329 Pasteboard Inspector[1616:303] Setting frame size:
{600, 226}
2014-04-23 14:44:47.345 Pasteboard Inspector[1616:303] Setting frame size:
{600, 228}
2014-04-23 14:44:47.362 Pasteboard Inspector[1616:303] Setting frame size:
{600, 229}
. cut to the end...
2014-04-23 14:44:50.179 Pasteboard Inspector[1616:303] Setting frame size:
{600, 352}
2014-04-23 14:44:50.229 Pasteboard Inspector[1616:303] Setting frame size:
{600, 352}

Okay, and here's what happens during collapse:

2014-04-23 14:45:23.047 Pasteboard Inspector[1616:303] Setting frame
origin: {0, 91}
2014-04-23 14:45:23.047 Pasteboard Inspector[1616:303] Setting frame size:
{600, 36}
2014-04-23 14:45:23.096 Pasteboard Inspector[1616:303] Setting frame
origin: {0, 91}
2014-04-23 14:45:23.096 Pasteboard Inspector[1616:303] Setting frame size:
{600, 36}
2014-04-23 14:45:23.097 Pasteboard Inspector[1616:303] Setting frame size:
{600, 347}
. cut to the middle...
2014-04-23 14:45:25.554 Pasteboard Inspector[1616:303] Setting frame
origin: {0, 91}
2014-04-23 14:45:25.554 Pasteboard Inspector[1616:303] Setting frame size:
{600, 36}
2014-04-23 14:45:25.555 Pasteboard Inspector[1616:303] Setting frame size:
{600, 136}
2014-04-23 14:45:25.595 Pasteboard Inspector[1616:303] Setting frame
origin: {0, 91}
2014-04-23 14:45:25.596 Pasteboard Inspector[1616:303] Setting frame size:
{600, 36}
2014-04-23 14:45:25.597 Pasteboard Inspector[1616:303] Setting frame size:
{600, 133}
. cut to the end...
2014-04-23 14:45:27.911 Pasteboard Inspector[1616:303] Setting frame
origin: {0, 91}
2014-04-23 14:45:27.911 Pasteboard Inspector[1616:303] Setting frame size:
{600, 36}
2014-04-23 14:45:27.912 Pasteboard Inspector[1616:303] Setting frame size:
{600, 36}

In other words, in the collapse, the view was getting the frame size set
twice on every animation update -- with the first size always being the
final goal size. I noticed that during the bogus frame set, the stack trace
is very similar but different in an important way - still triggered by
NSAnimationManager, but it's the superview frame change going through
resizeSubviewsWithOldSize: which triggers setFrameSize: on 'the' view. This
is indicative of the autoresize struts-springs model, yes?

The superview is a custom NSView only for the purpose of setting isFlipped;
it's the documentView of a scroll view's NSClipView. I noticed that, even
though this flip view had the Autoresize Subviews box OFF in IB, at runtime
after nib loading I found it was ON - perhaps some auto machinery by
scrollview? So I changed the code to force it NO after load. I was
extremely excited when I ran this change -- I found that it indeed did nuke
the unwanted frame change during the collapse, so that the log messages now
had a similar pattern during expand and collapse.

But did it solve my complaint? Well, it didn't look much better. I wonder
if possibly that setFrame: to the final destination frame at the very
beginning (see the XXX) is the problem? But if anything, would only cause a
blip not a long lasting jitter, right?

I suppose I could check the frame changes in FlipView to see if I need to
stop the same effect there. I wonder if possibly this is unavoidable when
inside NSScrollVIew.

Thanks for pointing me to something interesting!


On Wed, Apr 23, 2014 at 12:39 AM, Jakob Egger  wrote:

>
> > New questions:
> > 1. Is there any point in using addConstraint/removeConstraint in the
> NSAnimationContext grouping? Seems like it can go before beginGrouping.
>
> The important thing is that the frames are set inside the grouping.
> Updating constraints should not cause any frames to be set, only the
> layoutIfNeeded method should perform layout.
>
> > 2. As you can see in the code, I check to see if the implicit animation
> setting is there at runtime (added in 10.8). AFAICT there is no simple way
> to do the animation in 10.7 when the autolayout was added. Apple had an
> oversight in 10.7 and fixed it in 10.8?
>
> Hm. NSLayoutConstraint conforms to NSAnimatablePropertyContainer, so you
> could perform an animation by animating the constant, eg.
> [[collapseConstraint animator] setConstant: 20]. However I don't know for
> sure if this works on 10.7, it doesn't say in the docs.
>
> > 3. The jitter problem. It's even more

Re: Mouse cursors and overlapping sibling NSViews

2014-04-23 Thread edward taffel
if a control changes rendering on entry, as well as the cursor, mouseEntered is 
serviceable; if changing the cursor is the goal, cursorUpdate is clearer—better 
practice. unfortunately, if views overlap mouseMoved is still sent to the 
parent, which muddles the state directed adjustment anyway.

On Apr 23, 2014, at 8:57 PM, Quincey Morris 
 wrote:

> On Apr 23, 2014, at 16:58 , Ken Thomases  wrote:
> 
>> If the cursor is appropriate for a given view, that's a *strong* indication 
>> to the user that a click will act on that view.  So, the view controlling 
>> the cursor at a given point should also be the view that receives the click 
>> at that point.
> 
> Wait, did I miss something? Wasn’t Edward correct in pointing out that using 
> mouseMoved: to set the cursor is not correct, and cursorUpdate: should be 
> used instead (with tracking areas with NSTrackingCursorUpdate) should be 
> used. That mechanism already chooses the correct view to get set the cursor.
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/etaffel%40me.com
> 
> This email sent to etaf...@me.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbarItem view set to NSButton view, but not showing...

2014-04-23 Thread Peters, Brandon
“or if you were trying to plug in the button during init, which is too early).”

That may be it, as I was setting the toolbar item’s view to the button in 
init(). If not there then where?


On Apr 23, 2014, at 9:12 PM, Andy Lee mailto:ag...@mac.com>> 
wrote:

Oh well, it was worth a try, and at least you've confirmed some basic steps 
*are* working.

From your previous message it sounds like you also checked self.toolbarItem and 
it too was not nil (as it could have been if, for example, you'd forgotten to 
connect an outlet in IB -- or if you were trying to plug in the button during 
init, which is too early).

If I understand what Jerry was getting at, you might want to log the addresses 
of the toolbar item and the button, and at some later point in the program 
confirm everything's still where you think it is.  For example, you could put a 
breakpoint in the toolbar item's action method and look at sender.  (I *think* 
that makes sense, but it might not; I haven't made a toolbar in long time.)

As a really trivial sanity check, maybe instead of setting the image, you could 
set the title.  If you still have the problem, at least you know it's not 
related to setting the image.

--Andy

On Apr 23, 2014, at 8:47 PM, "Peters, Brandon" 
mailto:bap...@my.fsu.edu>> wrote:

Andy,

I inserted code to check for nil images and image position, here is what I got:
// set the original and alternate images...names are “opposite"
NSImage *image = [NSImage imageNamed:@"StopButtonAlternateIcon”];
if(image)
{
NSLog(@"Setting 1st image for stop button");
[_button setImage:image];
}
else
{
NSLog(@"Image is null for StopButtonAlternateIcon");
}

image = [NSImage imageNamed:@"StopButtonIcon"];
if(image)
{
NSLog(@"Setting 2nd image for stop button");
[_button setAlternateImage:image];
}
else
{
NSLog(@"Image is null for StopButtonIcon");
}

// image position
[_button setImagePosition:NSImageOnly];
NSLog(@"Image position: %lu", [_button imagePosition]);


From the console:
2014-04-23 20:41:18.394 3D Rolling Ball Simulator[6321:303] Setting 1st image 
for stop button
2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Setting 2nd image 
for stop button
2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Image position: 1

On Apr 23, 2014, at 7:59 PM, Andy Lee mailto:ag...@mac.com>> 
wrote:


On Apr 23, 2014, at 6:36 PM, Jerry Krinock 
mailto:je...@ieee.org>> wrote:


On 2014 Apr 23, at 15:13, Peters, Brandon 
mailto:bap...@my.fsu.edu>> wrote:

call [toolbaritem setView:view] and pass in the NSButton.

Try some bonehead debugging with NSLog().  Verify that toolbaritem is your 
target item at that point, in particular, that it is not nil.

Two more things you can easily check:

* [NSImage imageNamed:imageName] is not returning nil.
* What is your button's imagePosition?  If it's NSNoImage that might explain it.

--Andy

___

Cocoa-dev mailing list 
(Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/bap04e%40my.fsu.edu

This email sent to bap...@my.fsu.edu



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: NSToolbarItem view set to NSButton view, but not showing...

2014-04-23 Thread Peters, Brandon
I got it! The button code goes inside the validate() method, which one has to 
override for custom toolbar items with custom views/buttons. Everything works. 
Thanks for assistance everyone!

On Apr 23, 2014, at 10:50 PM, Peters, Brandon 
mailto:bap...@my.fsu.edu>> wrote:

“or if you were trying to plug in the button during init, which is too early).”

That may be it, as I was setting the toolbar item’s view to the button in 
init(). If not there then where?


On Apr 23, 2014, at 9:12 PM, Andy Lee 
mailto:ag...@mac.com>> wrote:

Oh well, it was worth a try, and at least you've confirmed some basic steps 
*are* working.

From your previous message it sounds like you also checked self.toolbarItem and 
it too was not nil (as it could have been if, for example, you'd forgotten to 
connect an outlet in IB -- or if you were trying to plug in the button during 
init, which is too early).

If I understand what Jerry was getting at, you might want to log the addresses 
of the toolbar item and the button, and at some later point in the program 
confirm everything's still where you think it is.  For example, you could put a 
breakpoint in the toolbar item's action method and look at sender.  (I *think* 
that makes sense, but it might not; I haven't made a toolbar in long time.)

As a really trivial sanity check, maybe instead of setting the image, you could 
set the title.  If you still have the problem, at least you know it's not 
related to setting the image.

--Andy

On Apr 23, 2014, at 8:47 PM, "Peters, Brandon" 
mailto:bap...@my.fsu.edu>> wrote:

Andy,

I inserted code to check for nil images and image position, here is what I got:
// set the original and alternate images...names are “opposite"
NSImage *image = [NSImage imageNamed:@"StopButtonAlternateIcon”];
if(image)
{
   NSLog(@"Setting 1st image for stop button");
   [_button setImage:image];
}
else
{
   NSLog(@"Image is null for StopButtonAlternateIcon");
}

image = [NSImage imageNamed:@"StopButtonIcon"];
if(image)
{
   NSLog(@"Setting 2nd image for stop button");
   [_button setAlternateImage:image];
}
else
{
   NSLog(@"Image is null for StopButtonIcon");
}

// image position
[_button setImagePosition:NSImageOnly];
NSLog(@"Image position: %lu", [_button imagePosition]);


From the console:
2014-04-23 20:41:18.394 3D Rolling Ball Simulator[6321:303] Setting 1st image 
for stop button
2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Setting 2nd image 
for stop button
2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Image position: 1

On Apr 23, 2014, at 7:59 PM, Andy Lee 
mailto:ag...@mac.com>> wrote:


On Apr 23, 2014, at 6:36 PM, Jerry Krinock 
mailto:je...@ieee.org>> wrote:


On 2014 Apr 23, at 15:13, Peters, Brandon 
mailto:bap...@my.fsu.edu>> wrote:

call [toolbaritem setView:view] and pass in the NSButton.

Try some bonehead debugging with NSLog().  Verify that toolbaritem is your 
target item at that point, in particular, that it is not nil.

Two more things you can easily check:

* [NSImage imageNamed:imageName] is not returning nil.
* What is your button's imagePosition?  If it's NSNoImage that might explain it.

--Andy

___

Cocoa-dev mailing list 
(Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/bap04e%40my.fsu.edu

This email sent to 
bap...@my.fsu.edu



___

Cocoa-dev mailing list 
(Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/bap04e%40my.fsu.edu

This email sent to bap...@my.fsu.edu

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

IOKit / OSX: How can I distinguish between "real hard disk" and mounted images?

2014-04-23 Thread Fritz-Ulrich Siewert
Hello,

I'm writing an application to monitor disk i/o in OSX. Most work is done, but 
now I'm stuck: I cannot find a way to distinguish between a real, physical 
volume (i.e. the SSD and the hard disk in my fusion drive) and some mounted, 
virtual volumes (i.e. an opened .dmg-file).

Can anybody help with that?

Thanks,
Fritz
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Socket Programming on iOS

2014-04-23 Thread Piotr Pszczółkowski
Hi,
maybe will be better to use NSFileHandle?

_fileHandle = [[NSFileHandle alloc] initWithFileDescriptor:];
NSData *buffer = [_fileHandle readDataOfLength:];

regards
Piotr


On 16 Apr 2014, at 20:42 , Dilum Nawanjana  wrote:

> Listening to a Port from an iOS device is not very easy task in cocoa
> framework. I tried to develop an app that works as a server to listen to a
> port to start the Client Server conversation. I have to read a lot before I
> create that app.
> 
> Working as a Client in iOS device is pretty easy. But when it comes to
> Server cocoa framework is not very much handy for that. We have to code
> using basic C language for the implementation.
> 
> Do you guys have any suggestion to make it easier?
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/piotr%40mobilesoft-lab.com
> 
> This email sent to pi...@mobilesoft-lab.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Problem with distributed objects in GUI cocoa apps

2014-04-23 Thread Costas Chatzinikolas
Hi everyone,

i recently made a set of 2 command lines apps in Cocoa, that use
Distributed objects to communicate. In fact, the first app is the client
that sends a message, the second app is the server the vends the object.
Everything works ok!!!

Then i tried to make these 2 apps GUI based. I used the same code. The
server vends the object, but the client is unable to get the connection. It
always gets a nil connection. In fact when i check the number of available
connections from the client using:

[NSConnection allConnections]

it always return zero connections. The only difference in my code is that
in the GUI server app, i don't use:

[[NSRunLoop currentRunLoop] run]

since the GUI app has its own runLoop.

I also have enabled the sandbox networking capabilities for both GUI apps.

Has anyone experience this behavior before me?

Thanks in advance...
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Problem with distributed objects in GUI cocoa apps

2014-04-23 Thread Charles Srstka
On Mar 30, 2014, at 3:28 AM, Costas Chatzinikolas 
 wrote:

> Hi everyone,
> 
> i recently made a set of 2 command lines apps in Cocoa, that use
> Distributed objects to communicate. In fact, the first app is the client
> that sends a message, the second app is the server the vends the object.
> Everything works ok!!!
> 
> Then i tried to make these 2 apps GUI based. I used the same code. The
> server vends the object, but the client is unable to get the connection. It
> always gets a nil connection. In fact when i check the number of available
> connections from the client using:
> 
> [NSConnection allConnections]
> 
> it always return zero connections. The only difference in my code is that
> in the GUI server app, i don't use:
> 
> [[NSRunLoop currentRunLoop] run]
> 
> since the GUI app has its own runLoop.
> 
> I also have enabled the sandbox networking capabilities for both GUI apps.
> 
> Has anyone experience this behavior before me?
> 
> Thanks in advance...

Distributed Objects is pretty old and crusty at this point. You might want to 
look into NSXPCConnection instead, which fixes a lot of problems that DO had, 
and is likely to be better supported.

Charles


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com