Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Charles Srstka
On Dec 17, 2012, at 5:29 PM, Kyle Sluder  wrote:

> On Mon, Dec 17, 2012, at 03:25 PM, Sean McBride wrote:
>> On Mon, 17 Dec 2012 23:15:15 +, Mike Abdullah said:
>> 
>>> For what it's worth, OS X v10.8 Mountain Lion finally fixes this by
>>> making open panels non-modal. I think apps do need to be built against
>>> the new SDK for it, rather than automatically switching over to such
>>> behaviour.
>> 
>> In in 10.8.2 now, and in TextEdit they are app-modal.  It's Info.list
>> shows LSMinimumSystemVersion=10.8.  Not the case for you?
> 
> Certainly not app-modal on my 10.8.2 machine. Nor is it modal in
> Preview.

On my 10.8.2 machine, it's app-modal in both apps.

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


Re: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Mike Abdullah

On 17 Dec 2012, at 23:29, Kyle Sluder  wrote:

> On Mon, Dec 17, 2012, at 03:25 PM, Sean McBride wrote:
>> On Mon, 17 Dec 2012 23:15:15 +, Mike Abdullah said:
>> 
>>> For what it's worth, OS X v10.8 Mountain Lion finally fixes this by
>>> making open panels non-modal. I think apps do need to be built against
>>> the new SDK for it, rather than automatically switching over to such
>>> behaviour.
>> 
>> In in 10.8.2 now, and in TextEdit they are app-modal.  It's Info.list
>> shows LSMinimumSystemVersion=10.8.  Not the case for you?
> 
> Certainly not app-modal on my 10.8.2 machine. Nor is it modal in
> Preview.

Maybe you have to be setup with an iCloud account too for the new behaviour? 
Would be a bit odd if that were true though.


___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Kyle Sluder
On Mon, Dec 17, 2012, at 03:25 PM, Sean McBride wrote:
> On Mon, 17 Dec 2012 23:15:15 +, Mike Abdullah said:
> 
> >For what it's worth, OS X v10.8 Mountain Lion finally fixes this by
> >making open panels non-modal. I think apps do need to be built against
> >the new SDK for it, rather than automatically switching over to such
> >behaviour.
> 
> In in 10.8.2 now, and in TextEdit they are app-modal.  It's Info.list
> shows LSMinimumSystemVersion=10.8.  Not the case for you?

Certainly not app-modal on my 10.8.2 machine. Nor is it modal in
Preview.

--Kyle Sluder
___

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: Dragging CALayer in an event loop

2012-12-17 Thread Seth Willits
On Dec 17, 2012, at 2:15 AM, Graham Cox wrote:

> When I drag a CALayer, it does not follow the mouse but snaps to its final 
> location after I exit the loop. I've tried forcing the view to redisplay 
> within the loop, etc but nothing works. How can I do this?

Use [CATransaction setDisableActions:YES]; inside the transaction. I don't 
think the animation duration being 0 has the exact same effect.



--
Seth Willits


___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Sean McBride
On Mon, 17 Dec 2012 23:15:15 +, Mike Abdullah said:

>For what it's worth, OS X v10.8 Mountain Lion finally fixes this by
>making open panels non-modal. I think apps do need to be built against
>the new SDK for it, rather than automatically switching over to such
>behaviour.

In in 10.8.2 now, and in TextEdit they are app-modal.  It's Info.list shows 
LSMinimumSystemVersion=10.8.  Not the case for you?

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Kyle Sluder
On Mon, Dec 17, 2012, at 03:15 PM, Mike Abdullah wrote:
> 
> On 17 Dec 2012, at 17:15, Sean McBride  wrote:
> 
> > On Sun, 16 Dec 2012 21:46:14 -0800, Kyle Sluder said:
> > 
> >>> Thanks Kyle. I know about beginWithCompletionHandler: , but I really need
> >>> a modal window at that point my application opens the open panel.
> >> 
> >> I have to ask, why?
> > 
> > Sometimes it's appropriate.  Apple seems to think so, as File > Open shows 
> > a modal open panel.
> 
> For what it's worth, OS X v10.8 Mountain Lion finally fixes this by
> making open panels non-modal. I think apps do need to be built against
> the new SDK for it, rather than automatically switching over to such
> behaviour.

Is this true for all open panels, or only ones that use the new
iCloud-aware open panel?

--Kyle Sluder
___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Mike Abdullah

On 17 Dec 2012, at 17:15, Sean McBride  wrote:

> On Sun, 16 Dec 2012 21:46:14 -0800, Kyle Sluder said:
> 
>>> Thanks Kyle. I know about beginWithCompletionHandler: , but I really need
>>> a modal window at that point my application opens the open panel.
>> 
>> I have to ask, why?
> 
> Sometimes it's appropriate.  Apple seems to think so, as File > Open shows a 
> modal open panel.

For what it's worth, OS X v10.8 Mountain Lion finally fixes this by making open 
panels non-modal. I think apps do need to be built against the new SDK for it, 
rather than automatically switching over to such behaviour.


___

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


Freshly created .xcmappingmodel seems to have incorrect version hashes

2012-12-17 Thread Sean McBride
Hi all,

I created a brand new .xcmappingmodel for version x to y of my xcdatamodel.  I 
don't change anything in the mapping GUI.  I clean.  I build.  I write some 
test code:

NSURL* url = ...App.app/Contents/Resources/VersionXToY.cdm
mappingModel = [[NSMappingModel alloc] initWithContentsOfURL:url]

for (NSEntityMapping* em in [mappingModel entityMappings])
{
id dn = [em destinationEntityName];
id dh = [em destinationEntityVersionHash];
NSLog(@"%@ = %@", dn, dh);
}

I then open up the VersionInfo.plist file within my .app and compare the entity 
hashes.

For most, the VersionInfo.plist matches the hashes extracted from the .cdm, but 
for 2 entities they do not.

How can this be?!  As I said, the xcmappingmodel is freshly created!

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: Simple question about storyboard

2012-12-17 Thread Alex Kac
Storyboards are iOS 5+ only.

On Dec 14, 2012, at 2:33 AM, Jingwei XU  wrote:

> Hi everyone,
> I am a newbie in iOS field. I have a question about storyboard. If I
> use storyboard in a project, is this project is not compatible for iOS
> 4.3.3?
> 
> Jingwei Xu



Alex Kac - President and Founder
Web Information Solutions, Inc. 

"It is useless for sheep to pass a resolution in favor of vegetarianism while 
wolves remain of a different opinion."
-- William Randolph Inge






___

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


LSSharedFileListInsertItemURL does not honor the display name or icon

2012-12-17 Thread Ben Staveley-Taylor
I am trying to add a new item to the Finder Sidebar Favorites 
kLSSharedFileListFavoriteItems list. The API for doing this, 
LSSharedFileListInsertItemURL, is not working for me. The Sidebar folder is 
created, but with a generic folder icon and the name taken from the target 
folder instead of the supplied display name. Can anyone see the error in the 
code below? All the API calls are returning noErr or other success codes; there 
is no error report.

The app is not Sandboxed.
Running on OS X 10.7.5.

Thanks if you can help,

-- Ben



+ (BOOL) createSidebarFavoritesIcon:(NSString *)targetPath 
displayName:(NSString *)name icon:(NSString *)iconPath
{
BOOL success = NO;

NSURL *folderURL = [NSURL fileURLWithPath:targetPath];

IconRef iconRef = NULL;

if (iconPath != nil)
{
NSURL *iconURL = [NSURL fileURLWithPath:iconPath];

FSRef iconFSRef;
CFURLGetFSRef((CFURLRef)iconURL, &iconFSRef);

OSStatus status = RegisterIconRefFromFSRef('MYAP', 'SFAV', 
&iconFSRef, &iconRef);
if (status != noErr)
{
NSLog(@"%s: RegisterIconRefFromFSRef failed, error code 
%d", __FUNCTION__, (int)status);
}
}

// Create a reference to the shared file list.
LSSharedFileListRef favoritesList = 
LSSharedFileListCreate(kCFAllocatorDefault,
kLSSharedFileListFavoriteItems,
NULL);

if (favoritesList != NULL)
{
LSSharedFileListItemRef item = 
LSSharedFileListInsertItemURL(favoritesList,
kLSSharedFileListItemLast,
(CFStringRef)name,  // inDisplayName -- defaults to 
the folder name
iconRef,
(CFURLRef)folderURL,
NULL,   // inPropertiesToSet
NULL// inPropertiesToClear
);

if (item != NULL)
{
success = YES;
CFRelease(item);
}

CFRelease(favoritesList);
}

return success;
}


___

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


Simple question about storyboard

2012-12-17 Thread Jingwei XU
Hi everyone,
 I am a newbie in iOS field. I have a question about storyboard. If I
use storyboard in a project, is this project is not compatible for iOS
4.3.3?

Jingwei Xu


-- 
ICS Group
State Key Laboratory for Novel Software Technology
Department of Computer Science and Technology
Nanjing University

Addr: 163 Xianlin Road, Nanjing 210046, P. R. China
___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Sean McBride
On Sun, 16 Dec 2012 11:45:29 +0100, Tamas Nagy said:

>I'm trying to display an NSOpenPanel on a dispatch, with half-luck. The
>panel displays, but no files going to be displayed - the circle just
>spinning on the bottom-left corner. Anyone have an idea what going wrong?

Others have explained what's going on here.

There is a UI workaround... if you switch between icon and list view, it prods 
the thing into working.

I'll just add that my bug on this is .  I consider it 
unlikely to get fixed given the time that's elapsed.

In my case I was showing an openpanel during document opening (to prompt the 
user to find a file if an alias failed to resolve).  Between 10.6 and 10.7, 
with all the doc architecture changes, an override point in NSDocument starting 
using GCD and suddenly modal openpanels become unsafe to use there. :(

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: Dragging CALayer in an event loop

2012-12-17 Thread Kyle Sluder
On Dec 17, 2012, at 2:15 AM, Graham Cox  wrote:

> I have a very simple piece of code that doesn't behave how I expected it to.
> 
> When I drag a CALayer, it does not follow the mouse but snaps to its final 
> location after I exit the loop. I've tried forcing the view to redisplay 
> within the loop, etc but nothing works. How can I do this?
> 
> 
> 
> 
> - (BOOL)dragItems:(NSSet*) items withEvent:(NSEvent*) event
> {
>// keeps control and moves the set of items as the mouse is dragged
>
>NSUIntegermask = NSLeftMouseDragged | NSLeftMouseUp | NSLeftMouseDown;
>BOOLdone = NO;
>BOOLdragged = NO;
>NSPointprevious, local;
>
>previous = [event locationInWindow];
>
>while( !done )
>{
>event = [self.view.window nextEventMatchingMask:mask untilDate:[NSDate 
> distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES];
>[self.view.window discardEventsMatchingMask:NSAnyEventMask 
> beforeEvent:event];
>
>local = [event locationInWindow];
>
>NSPoint delta = NSMakePoint( local.x - previous.x, local.y - 
> previous.y );
>previous = local;
>
>// move the layers' positions by 
>
>[CATransaction begin];
>[CATransaction setAnimationDuration:0];
> 
>for( CALayer* layer in items )
>{
>CGPoint pos = layer.position;
>
>pos.x += delta.x;
>pos.y -= delta.y;
>
>layer.position = pos;
>}
>
>[CATransaction commit];

What if you call +flush before committing the transaction? CATransaction is 
dependent on the runloop to close its enclosing implicit transactions. This 
might not happen in the event-tracking runloop mode.

(iI only Apple would document what runloop mode(s) CA relies on…)

--Kyle Sluder
___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Sean McBride
On Sun, 16 Dec 2012 21:46:14 -0800, Kyle Sluder said:

>> Thanks Kyle. I know about beginWithCompletionHandler: , but I really need
>> a modal window at that point my application opens the open panel.
>
>I have to ask, why?

Sometimes it's appropriate.  Apple seems to think so, as File > Open shows a 
modal open panel.

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: Dragging CALayer in an event loop

2012-12-17 Thread Gordon Apple
I would recommend subclassing CALayer and using a notification to update its
position.  Without more detail, I can¹t tell you exactly how to do this.  I
use movie layers which do track underlying draw objects when I drag them.


On 12/17/12 6:14 AM, "cocoa-dev-requ...@lists.apple.com"
 wrote:

> I have a very simple piece of code that doesn't behave how I expected it to.
> When I drag a CALayer, it does not follow the mouse but snaps to its final
> location after I exit the loop. I've tried forcing the view to redisplay
> within the loop, etc but nothing works. How can I do this?


___

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: NSWorkspace recycleURLs:completionHandler error -5000 (afpAccessDenied)

2012-12-17 Thread Kyle Sluder
On Mon, Dec 17, 2012, at 07:54 AM, Jon Gary wrote:
> Containers/MyBundleId/Data/Library/Application
> Support/MyApp/MyFolderWhereRecycleFails

If the file is on a remote volume, the trash directory is actually
/Volumes/$REMOTE_VOLUME/.Trashes/$UID.

Sounds like the document is on an AFP volume and they might not be able
to create their trash directory.

--Kyle Sluder
___

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: NSWorkspace recycleURLs:completionHandler error -5000 (afpAccessDenied)

2012-12-17 Thread Jon Gary
Containers/MyBundleId/Data/Library/Application 
Support/MyApp/MyFolderWhereRecycleFails
--
Jon Gary / Object Orienteer / Ambrosia Software, Inc. -- 
http://www.AmbrosiaSW.com/



On Dec 14, 2012, at 6:51 PM, Mike Abdullah wrote:

> 
> On 14 Dec 2012, at 21:26, Jon Gary wrote:
> 
>> I have a sandboxed app that creates a file in a folder within the app's 
>> sandbox container. When the app is done with the file, it is moved to the 
>> trash using recycleURLs:completionHandler. A few of our users are reporting 
>> the "you do not have permision to move the file to the trash." I've checked 
>> the permissions on the file itself and the user has read and write accces. 
>> We've had them run a shell command to make sure they have write access to 
>> their trash directory. None of this helps. I'm stumped.
>> 
>> I've asked the user if they are using a networked home directory, but they 
>> say no (I'm not sure they understood the question).
>> 
>> Any clues?
> 
> When you say inside the app's sandbox container, where specifically are we 
> talking?
> 


___

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: Property Declared in a Category and Sent to id

2012-12-17 Thread Andreas Grosam

On 17.12.2012, at 13:14, Roland King wrote:

> 
> On 17 Dec, 2012, at 7:20 PM, Andreas Grosam  wrote:
> 
>> 
>> On 17.12.2012, at 11:25, Andreas Grosam wrote:
>> 
>>> I would like to use the property access syntax for a (readonly) property 
>>> which is defined in a category and sent to an object whose compile type 
>>> info is just "id". Use case:
>>> 
>>> id obj = …;
>>> if (obj.isFoo) {   // <== error: property 'isFoo' not found for object of 
>>> type '__strong id'.
>>>   ...
>>> }
>>> 
>>> 
>>> So, why does message send syntax compiles fine - but property syntax not??
>> 
>> Well, after thinking a while about the issue, I can answer this myself:
>> 
>> The compiler requires the type information in order to figure the actual 
>> getter signature. When declaring the a property, the getter and setter may 
>> be explicitly specified, for example:
>> 
>> @property (readonly, getter=getFooStateOrWhatever) isFoo;
>> 
>> Thus, the compiler cannot deduce the setter and getter methods from the 
>> property name unless it knows the type. So, in the case above where the type 
>> is not known at compile time, I cannot use dot syntax but needs to use 
>> method send syntax with the actual getter signature.
>> 
>> Andreas
>> 
> 
> Don't see that at all, sorry. The dot syntax a.foo is just another way of 
> saying [ a foo ], they are equivalent.
No, this is not the case. The compiler requires the declaration of the property 
when it encounters a dot syntax, in order to figure the *actual* method 
signature of the getter or setter. Most often, the method names for the setter 
and getter are the "canonical names" (`foo`, `setFoo:`), since per default the 
setter and getter are not specified. 

For example, the property could have been declared as

@property (readonly, getter=foo) BOOL isFoo;

So, in this case, in order to compile properly, the compiler will issue code 
for 

if (obj.isFoo) {
}

that is equivalent to

if ([obj foo]) {
}

and NOT 

if ([obj isFoo]) {
}


When the compiler does not, or cannot find the declaration of the property, it 
cannot just guess the name of the setter/getter. So, it signals an error. It 
cannot find the declaration of the property if the type is just `id`, for 
example. So, this will issue an error:

id obj = …
if (obj.isFoo) {
}

Whether it should signal an error or just issue a warning is debatable, IMO.



But, we are allowed to send any message to any object - using method send 
syntax:

id obj = …
if ([obj isFoo]) {   <== ohps!
}

id obj = …
if ([obj foo]) {   <== fine!
}




Andreas
___

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

[SOLVED] Re: Dragging CALayer in an event loop

2012-12-17 Thread Graham Cox
OK, this is a bit weird, but I found a simple solution. If I add 
NSOtherMouseDraggedMask to my list of masks, it works fine, even though in the 
body of the code I now only actually move the layers for the NSLeftMouseDragged 
event type! In addition, the docs for NSOtherMouseDraggedEvent suggest it 
applies only to a mouse with >2 buttons, for a button other than left or right. 
My mouse is a simple 2-button mouse, so that should not apply.

Lately, I've been finding all sorts of weird event handling oddities like this 
which suggests that there may be some strange bugs in the event queueing stuff. 
I had a huge hassle trying to get events in a sensible order when responding to 
trackpad events in a similar loop.

Any insight from somebody who knows more about this stuff would be appreciated 
- right now I'm finding there is far too much "magic" needed to make things 
work and none of it is adequately documented.



--Graham





On 17/12/2012, at 9:15 PM, Graham Cox  wrote:

> I have a very simple piece of code that doesn't behave how I expected it to.
> 
> When I drag a CALayer, it does not follow the mouse but snaps to its final 
> location after I exit the loop. I've tried forcing the view to redisplay 
> within the loop, etc but nothing works. How can I do this?
> 
> 
> 
> 
> - (BOOL)  dragItems:(NSSet*) items withEvent:(NSEvent*) event
> {
>   // keeps control and moves the set of items as the mouse is dragged
>   
>   NSUInteger  mask = NSLeftMouseDragged | NSLeftMouseUp | 
> NSLeftMouseDown;
>   BOOLdone = NO;
>   BOOLdragged = NO;
>   NSPoint previous, local;
>   
>   previous = [event locationInWindow];
>   
>   while( !done )
>   {
>   event = [self.view.window nextEventMatchingMask:mask 
> untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode 
> dequeue:YES];
>   [self.view.window discardEventsMatchingMask:NSAnyEventMask 
> beforeEvent:event];
>   
>   local = [event locationInWindow];
>   
>   NSPoint delta = NSMakePoint( local.x - previous.x, local.y - 
> previous.y );
>   previous = local;
>   
>   // move the layers' positions by 
>   
>   [CATransaction begin];
>   [CATransaction setAnimationDuration:0];
> 
>   for( CALayer* layer in items )
>   {
>   CGPoint pos = layer.position;
>   
>   pos.x += delta.x;
>   pos.y -= delta.y;
>   
>   layer.position = pos;
>   }
>   
>   [CATransaction commit];
>   
>   if( event.type == NSLeftMouseUp )
>   done = YES;
>   else if ( event.type == NSLeftMouseDragged )
>   dragged = YES;
>   }
>   
>   return dragged;
> }
> 
> 
> --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/graham.cox%40bigpond.com
> 
> This email sent to graham@bigpond.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: Property Declared in a Category and Sent to id

2012-12-17 Thread Roland King

On 17 Dec, 2012, at 7:20 PM, Andreas Grosam  wrote:

> 
> On 17.12.2012, at 11:25, Andreas Grosam wrote:
> 
>> I would like to use the property access syntax for a (readonly) property 
>> which is defined in a category and sent to an object whose compile type info 
>> is just "id". Use case:
>> 
>> id obj = …;
>> if (obj.isFoo) {   // <== error: property 'isFoo' not found for object of 
>> type '__strong id'.
>>   ...
>> }
>> 
>> 
>> So, why does message send syntax compiles fine - but property syntax not??
> 
> Well, after thinking a while about the issue, I can answer this myself:
> 
> The compiler requires the type information in order to figure the actual 
> getter signature. When declaring the a property, the getter and setter may be 
> explicitly specified, for example:
> 
> @property (readonly, getter=getFooStateOrWhatever) isFoo;
> 
> Thus, the compiler cannot deduce the setter and getter methods from the 
> property name unless it knows the type. So, in the case above where the type 
> is not known at compile time, I cannot use dot syntax but needs to use method 
> send syntax with the actual getter signature.
> 
> Andreas
> 

Don't see that at all, sorry. The dot syntax a.foo is just another way of 
saying [ a foo ], they are equivalent. The compiler has no more information one 
way or another, it doesn't need to deduce the setter and getter methods, it 
just needs to call the method you've asked it to call, whether the object will 
end up responding to it or not. 

I think the answer is much more to do with being modern. Dot syntax is 
relatively new, and somewhat mirrors the . syntax for structs. They have no 
choice but to allow [ obj selector ] with a random id and selector to be 
acceptable syntax, too much old code using it and you do need a way to say 
'just send it please'. But there was no particular reason to carry that over 
into the dot syntax world and so they didn't and require that an object you ask 
for a property on, or set a property on, is typed. 
___

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: Property Declared in a Category and Sent to id

2012-12-17 Thread Andreas Grosam

On 17.12.2012, at 11:25, Andreas Grosam wrote:

> I would like to use the property access syntax for a (readonly) property 
> which is defined in a category and sent to an object whose compile type info 
> is just "id". Use case:
> 
> id obj = …;
> if (obj.isFoo) {   // <== error: property 'isFoo' not found for object of 
> type '__strong id'.
>...
> }
> 
> 
> So, why does message send syntax compiles fine - but property syntax not??

Well, after thinking a while about the issue, I can answer this myself:

The compiler requires the type information in order to figure the actual getter 
signature. When declaring the a property, the getter and setter may be 
explicitly specified, for example:

@property (readonly, getter=getFooStateOrWhatever) isFoo;

Thus, the compiler cannot deduce the setter and getter methods from the 
property name unless it knows the type. So, in the case above where the type is 
not known at compile time, I cannot use dot syntax but needs to use method send 
syntax with the actual getter signature.

Andreas


___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tamas Nagy
Yep, its a design bug for sure, which I should and will fix.

On Dec 17, 2012, at 11:14 AM, Tom Davie  wrote:

> 
> On 17 Dec 2012, at 10:11, Tamas Nagy  wrote:
> 
>> There is a chance in the application where only one,  borderless window 
>> displayed on the secondary screen, so there are possible circumstances where 
>> displaying a window-modal panel not quite useful.
> 
> Okay, but your example of when modality was required involved a project being 
> in an inconsistent state, and requiring information from the open dialog 
> before it was complete… In this scenario the open dialog can be attached to 
> the inconsistent project's window.
> 
> Or are you trying to assert that you can have the app sat there, doing 
> nothing, with no significant windows open, yet in an inconsistent state, and 
> requiring modal interaction to sort it out?
> 
> If that's your assertion, then I'd suggest you have a deeper seated design 
> bug.
> 
> Thanks
> 
> Tom Davie


___

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: Correct way to make mutable and immutable objects?

2012-12-17 Thread Graham Cox
Thanks for your insights guys...

I think the separate header for the mutating methods in a category should be 
enough in this case.

--Graham



On 16/12/2012, at 8:28 AM, Jens Alfke  wrote:

> 
> On Dec 14, 2012, at 3:25 PM, Graham Cox  wrote:
> 
>> I have an abstract base class A and a mutable subclass AM. The class A owns 
>> a list of subsidiary objects but only the class AM has the methods for 
>> adding and removing these , which is what 'mutable' means for this class.
>> 
>> There are a series of concrete subclasses B, C, D, etc which all set up the 
>> subsidiary objects in various configurations when they are initialized, but 
>> once done, the clients of these objects have no business mutating them so 
>> they need to be returned as the immutable variant.
> 
> This is a classic OOP design problem — it’s one of the things multiple 
> inheritance or mixins are supposed to solve. You’d make the mutability API a 
> mixin class that could be inherited by mutable subclasses of A, B, C, etc — 
> AM, BM, CM. There’s no way to do this in Obj-C, though — and in practice this 
> capability tends to introduce all kinds of complications in languages that 
> support it like C++.
> 
>> However, in order to work during setup they are in fact subclasses of AM.
> 
> That’s one way to do it in Obj-C. Another way is to get rid of the 
> distinction between A and AM and just make mutability a boolean attribute of 
> an instance. The mutating methods can have assertions that check this. This 
> is the way that the collection classes in Foundation/CF work.
> 
>> Is there a way to return them as if they were subclasses of A, so that the 
>> existence of the mutating methods is hidden from the client code?
>> It only needs to go as far as flagging a compile warning if the client 
>> attempts to use a mutating method
> 
> I’d put the mutating methods in a category in a separate header file. That 
> way the code that needs to use them can #import that header and use the API, 
> but it’s not generally known to clients.
> 
> —Jens
> 

___

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

Dragging CALayer in an event loop

2012-12-17 Thread Graham Cox
I have a very simple piece of code that doesn't behave how I expected it to.

When I drag a CALayer, it does not follow the mouse but snaps to its final 
location after I exit the loop. I've tried forcing the view to redisplay within 
the loop, etc but nothing works. How can I do this?




- (BOOL)dragItems:(NSSet*) items withEvent:(NSEvent*) event
{
// keeps control and moves the set of items as the mouse is dragged

NSUInteger  mask = NSLeftMouseDragged | NSLeftMouseUp | 
NSLeftMouseDown;
BOOLdone = NO;
BOOLdragged = NO;
NSPoint previous, local;

previous = [event locationInWindow];

while( !done )
{
event = [self.view.window nextEventMatchingMask:mask 
untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:YES];
[self.view.window discardEventsMatchingMask:NSAnyEventMask 
beforeEvent:event];

local = [event locationInWindow];

NSPoint delta = NSMakePoint( local.x - previous.x, local.y - 
previous.y );
previous = local;

// move the layers' positions by 

[CATransaction begin];
[CATransaction setAnimationDuration:0];

for( CALayer* layer in items )
{
CGPoint pos = layer.position;

pos.x += delta.x;
pos.y -= delta.y;

layer.position = pos;
}

[CATransaction commit];

if( event.type == NSLeftMouseUp )
done = YES;
else if ( event.type == NSLeftMouseDragged )
dragged = YES;
}

return dragged;
}


--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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tom Davie

On 17 Dec 2012, at 10:11, Tamas Nagy  wrote:

> There is a chance in the application where only one,  borderless window 
> displayed on the secondary screen, so there are possible circumstances where 
> displaying a window-modal panel not quite useful.

Okay, but your example of when modality was required involved a project being 
in an inconsistent state, and requiring information from the open dialog before 
it was complete… In this scenario the open dialog can be attached to the 
inconsistent project's window.

Or are you trying to assert that you can have the app sat there, doing nothing, 
with no significant windows open, yet in an inconsistent state, and requiring 
modal interaction to sort it out?

If that's your assertion, then I'd suggest you have a deeper seated design bug.

Thanks

Tom Davie
___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tamas Nagy
There is a chance in the application where only one,  borderless window 
displayed on the secondary screen, so there are possible circumstances where 
displaying a window-modal panel not quite useful.



On Dec 17, 2012, at 10:50 AM, Tom Davie  wrote:

> 
> On 17 Dec 2012, at 09:42, Tamas Nagy  wrote:
> 
>> The user is still able to control things like fading with a MIDI/OSC 
>> controller - they definitely do not do that with mouse. But there are things 
>> which only controllable with the UI, deleting layers for example. And there 
>> are some circumstances - for example, loading a whole project, where the 
>> app's state just reseted before displaying the open panel, and the loading 
>> process presume everything is clear when iterating thru the load data, so it 
>> could would be bad if the app's "clear state" can change when an open panel 
>> is opened. 
> 
> Wouldn't the correct thing in this state be to create a new project window 
> associated with the project document, and then fire of an open sheet for that 
> window so that it's only modal for the window?
> 
> Thanks
> 
> Tom Davie


___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tom Davie

On 17 Dec 2012, at 09:42, Tamas Nagy  wrote:

> The user is still able to control things like fading with a MIDI/OSC 
> controller - they definitely do not do that with mouse. But there are things 
> which only controllable with the UI, deleting layers for example. And there 
> are some circumstances - for example, loading a whole project, where the 
> app's state just reseted before displaying the open panel, and the loading 
> process presume everything is clear when iterating thru the load data, so it 
> could would be bad if the app's "clear state" can change when an open panel 
> is opened. 

Wouldn't the correct thing in this state be to create a new project window 
associated with the project document, and then fire of an open sheet for that 
window so that it's only modal for the window?

Thanks

Tom Davie
___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tamas Nagy
The user is still able to control things like fading with a MIDI/OSC controller 
- they definitely do not do that with mouse. But there are things which only 
controllable with the UI, deleting layers for example. And there are some 
circumstances - for example, loading a whole project, where the app's state 
just reseted before displaying the open panel, and the loading process presume 
everything is clear when iterating thru the load data, so it could would be bad 
if the app's "clear state" can change when an open panel is opened. 

On Dec 17, 2012, at 10:29 AM, Tom Davie  wrote:

> 
> On 17 Dec 2012, at 09:26, Tamas Nagy  wrote:
> 
>> I really appreciate your continuous curiosity guys, but we just getting 
>> off-topic :)
>> 
>> BTW, its a realtime graphics application, where UI events should not 
>> blocking rendering. Think about a concert where some videos projected behind 
>> the band, it would be bad if opening the next video - putting it into some 
>> kind of queue - blocks the rendering/displaying the current video. 
> 
> You're right, it would be bad… Surely that's a good reason why it would be 
> bad that the user of such an app couldn't go "oh crap, I forgot to start that 
> fade", and start it, with the open panel for the next video open?
> 
> Thanks
> 
> Tom Davie


___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tom Davie

On 17 Dec 2012, at 09:26, Tamas Nagy  wrote:

> I really appreciate your continuous curiosity guys, but we just getting 
> off-topic :)
> 
> BTW, its a realtime graphics application, where UI events should not blocking 
> rendering. Think about a concert where some videos projected behind the band, 
> it would be bad if opening the next video - putting it into some kind of 
> queue - blocks the rendering/displaying the current video. 

You're right, it would be bad… Surely that's a good reason why it would be bad 
that the user of such an app couldn't go "oh crap, I forgot to start that 
fade", and start it, with the open panel for the next video open?

Thanks

Tom Davie
___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tamas Nagy
I really appreciate your continuous curiosity guys, but we just getting 
off-topic :)

BTW, its a realtime graphics application, where UI events should not blocking 
rendering. Think about a concert where some videos projected behind the band, 
it would be bad if opening the next video - putting it into some kind of queue 
- blocks the rendering/displaying the current video. 

On Dec 17, 2012, at 10:06 AM, Tom Davie  wrote:

> 
> On 17 Dec 2012, at 05:58, Tamas Nagy  wrote:
> 
>> It's a live video app, where rendering happening on a CVDisplayLink thread, 
>> so the app still running and do its job while an OpenPanel (or SavePanel) 
>> displaying. I just need to block the UI to make sure the users can't 
>> interact the app while an open panel displaying. 
> 
> But why?
> 
> What's the issue with the user pausing a video while an open panel happens to 
> be open?
> 
> Thanks
> 
> Tom Davie


___

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: NSOpenPanel runModal on a dispatch

2012-12-17 Thread Tom Davie

On 17 Dec 2012, at 05:58, Tamas Nagy  wrote:

> It's a live video app, where rendering happening on a CVDisplayLink thread, 
> so the app still running and do its job while an OpenPanel (or SavePanel) 
> displaying. I just need to block the UI to make sure the users can't interact 
> the app while an open panel displaying. 

But why?

What's the issue with the user pausing a video while an open panel happens to 
be open?

Thanks

Tom Davie
___

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