NSForegroundColorAttributeName without AppKit
Hi all, I have some working code for adding attributes to a string. I'd like to modify it so it will work without needing AppKit. I can get it all going except the NSForegroundColorAttributeName constant which seems to only exist in AppKit. Here's an example: NSColor* tokenColor = [NSColor red]; NSDictionary* tokenAttributesDict = [NSDictionary dictionaryWithObject:tokenColor forKey:NSForegroundColorAttributeName]; NSRange tokenRange = NSMakeRange(startCharN, [token length]); [tokenizedAttributedString addAttributes:tokenAttributesDict range:tokenRange]; Is there an alternative to NSForegroundColorAttributeName I can use without needing AppKit? Thanks, Tom BareFeet ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Question about NSScrollView
Hi all ! So I have a question on how to resolve a little issue I have with NSScrollView. I have created everything programmatically (a little exploration task to learn and understand how to do stuff without IB). I have an NSOutlineView enclosed in an NSScrollView (as recommended by documentation). All works good except for little thing. Since NSOutlineView is not populated, content area is empty, but vertical scroller knob is shown (horizontal not showed). Question: Why ? I googled for an answer and got some facts together but don't really know how to get to the solution to rectify the issue. Facts: Scroller in this situation is shown because NSOutlineView has NSTableHeader shown (instantiated). If I set NSOutlineView headerView to nil, it gets released and not shown in the NSScrollView, and then there is no scroller knob. But what if I want to have NSTableHeader ? Seams to me that if the headerView is ON, NSScrollView makes wrong calculation of how much is the content area big and how much should it be shown. I have been examining the documentation for NSScrollView and NSClipView and found couple of methods that has something to do regarding that but I don't know to make a use of them. If any one knows something which could point me to the solution it will be much appreciated. Thanks in advance. Bye. P.S. example picture in attachment inline: window.jpg Mario Kušnjer mario.kusn...@sb.t-com.hr +385957051982 mariokusnjer (at) Skype ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSForegroundColorAttributeName without AppKit
On 19/02/2010, at 7:05 PM, BareFeet wrote: I have some working code for adding attributes to a string. I'd like to modify it so it will work without needing AppKit. I can get it all going except the NSForegroundColorAttributeName constant which seems to only exist in AppKit. If you log the actual value of that constant, it's simply @NSColor. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about NSScrollView
tell your NSScrollView to setAutoHidesScrollers:yes This should hide the scrollbars until needed. http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSScrollView_Class/Reference/Reference.html On Feb 19, 2010, at 3:10 AM, Mario Kušnjer wrote: Hi all ! So I have a question on how to resolve a little issue I have with NSScrollView. I have created everything programmatically (a little exploration task to learn and understand how to do stuff without IB). I have an NSOutlineView enclosed in an NSScrollView (as recommended by documentation). All works good except for little thing. Since NSOutlineView is not populated, content area is empty, but vertical scroller knob is shown (horizontal not showed). Question: Why ? I googled for an answer and got some facts together but don't really know how to get to the solution to rectify the issue. Facts: Scroller in this situation is shown because NSOutlineView has NSTableHeader shown (instantiated). If I set NSOutlineView headerView to nil, it gets released and not shown in the NSScrollView, and then there is no scroller knob. But what if I want to have NSTableHeader ? Seams to me that if the headerView is ON, NSScrollView makes wrong calculation of how much is the content area big and how much should it be shown. I have been examining the documentation for NSScrollView and NSClipView and found couple of methods that has something to do regarding that but I don't know to make a use of them. If any one knows something which could point me to the solution it will be much appreciated. Thanks in advance. Bye. P.S. example picture in attachment window.jpg Mario Kušnjer mario.kusn...@sb.t-com.hr +385957051982 mariokusnjer (at) Skype ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/intrntmn%40aol.com This email sent to intrn...@aol.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
what is a bindings pattern to check for a non-empty selection?
Hello, I have tried to search for an answer to that question, and I'm sure it must exist somewhere, but bindings and select or selection are definitely not specific enough. I am looking for a way to enable a button in my window only if some selection has been made in the data. Currently the data is shown in a table view and is handled through an NSArrayController. I am trying to bind the button's Enabled property to the ArrayController so that I get whether something is selected (multiple selections allowed). I have tried bindings to selectedObjects using the model key count, as a non zero count is obviously compatible with the BOOL that the property expects. But this doesn't work: I get an error message: Cannot create BOOL from object () of class __NSArray0 I really don't understand that error message, as the count message returns an integer, not an object. Can anybody explain? I finally manage to use the canRemove key of the arrayController. It seems to work, but I feel nervous about it. I don't like the name of it. Of course at first glance, it seems you can't remove unless you have a non-empty selection, but other conditions may apply (not locked, whatever). So is the canRemove the commonly accepted practice to test for a non empty selection in an table view using an NSArrayController? Is there a reason for NSArrayController (or NSObjectController for that matter) not to have a hasSelection predicate available? Or is there another better pattern? (though the question is in the context of an table view and an NSArrayController, it might possibly be asked in a wider context). Many thanks, Jean-Denis ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about NSScrollView
On 2010.02.19, at 11:43, Jack Carbaugh wrote: tell your NSScrollView to setAutoHidesScrollers:yes This should hide the scrollbars until needed. http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSScrollView_Class/Reference/Reference.html That's one of the solutions. But then I could also remove headerView and evade the problem in the first place. What would be solution if I want to have vertical scroller visible ? I'm thinking more in the way of somehow recalculating contentView area before it gets send to the NSClipView to be displayed. Correct ? Wrong? Thanks for suggestions. Mario Kušnjer mario.kusn...@sb.t-com.hr +385957051982 mariokusnjer (at) Skype ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Minor resize trouble with NSScrollView
Hi, I have a window which is split into two views (one atop the other). Both are NSScrollView instances containing a subclass of NSCollectionView (in an NSScrollView). The layout of the two views is dynamic -- sometimes only the top one is visible ( and takes up the full space ) and sometimes both views are visible. I use an NSAnimation to animate the transition by dynamically resizing. Here's some ASCII art to show what I'm talking about: | top| | | - | top only | ( bottom squished to 0 height ) | bottom | | | The transition is performed by using an NSAnimation to animate the collapse of the bottom view, and during the layout process the top view's frame is expanded to fill the entire space. This whole thing works correctly when not animating -- and layout also works correctly when manually resizing the window. The trouble is that when using NSAnimation the scrollviews don't always resize the child collection views. In short, when animating, it would appear that the scrollview's frame/bounds are changed, but it's not updating its content view. I've tried some special case code in my layout loop to detect scroll views and force the -tile function to be called, but it doesn't help. Here's the relevant bits of code -- the NSAnimation subclass which triggers layout updates: @implementation CollapseAnimation - (void)setCurrentProgress:(NSAnimationProgress)progress { [super setCurrentProgress:progress]; [(StackView*)[self delegate] setCollapseProgress: [self currentValue]]; } @end And here's the StackView class which does the laying out: @implementation StackView - (void) setCollapseProgress: (CGFloat) progress { collapseProgress = MIN(MAX(progress,0),1); [self layout]; } - (void) layout { if ( layingOut || !self.subviews.count ) return; layingOut = YES; NSArray *children = [self.subviews reversedArray]; NSMutableArray *tokens = [NSMutableArray arrayWithCapacity: children.count]; for ( NSView *v in children ) { CGFloat collapse = [self collapseForView: v]; if ( [v respondsToSelector: @selector(preferredHeight)] ) { [tokens addObject: [LayoutToken layoutTokenWithPreferredSize: [(id)v preferredHeight] andCollapse: collapse ]]; } else { [tokens addObject: [LayoutToken layoutTokenWithPreferredSize: v.bounds.size.height andCollapse: collapse]]; } } [self generateLayoutForTokens: tokens availableSize: self.bounds.size.height]; CGFloat y = self.bounds.size.height; for ( NSUInteger i = 0, N = children.count; i N; i++ ) { NSView *v = [children objectAtIndex: i]; LayoutToken *t = [tokens objectAtIndex:i]; CGFloat width = self.bounds.size.width, height = t.layoutSize; v.frame = NSMakeRect( 0, y - height, width, height ); y -= height; if ( [v isKindOfClass: [NSScrollView class]] ) { [(NSScrollView*)v tile]; } DebugLog( @Set frame for view %@ with collapse: %f to %@, v, [self collapseForView: v], NSStringFromRect( v.frame )); } printf( \n ); layingOut = NO; } @end Any ideas? -- shamyl zakariya - so much for pathos ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: what is a bindings pattern to check for a non-empty selection?
On 2010 Feb 19, at 03:02, Jean-Denis Muys wrote: I am trying to bind the button's Enabled property to the ArrayController so that I get whether something is selected (multiple selections allowed). In code, write a simple subclass of NSValueTransformer, nonreversible, which transforms an array to a BOOL, returning YES if the array is nonempty. Add it to your project, then specify it in the binding. Search Xcode documentation for Value Transformer Programming Guide and read it. I have tried bindings to selectedObjects using the model key count, as a non zero count is obviously compatible with the BOOL that the property expects. But this doesn't work: I get an error message: Cannot create BOOL from object () of class __NSArray0 It means that it wants a BOOL but the selectedObjects you're giving it is an array. I really don't understand that error message, as the count message returns an integer, not an object. Can anybody explain? In this case, there is no object involved. I finally manage to use the canRemove key of the arrayController. Cute trick. It seems to work, but I feel nervous about it. I don't like the name of it. Of course at first glance, it seems you can't remove unless you have a non-empty selection, but other conditions may apply (not locked, whatever). I agree; it does look rather fragile. So is the canRemove the commonly accepted practice to test for a non empty selection in an table view using an NSArrayController? I wouldn't ship it. Is there a reason for NSArrayController (or NSObjectController for that matter) not to have a hasSelection predicate available? Probably because Apple has 5 million bugs open and not many people have requested this. Or is there another better pattern? Value Transformer. (though the question is in the context of an table view and an NSArrayController, it might possibly be asked in a wider context). Same answer. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: what is a bindings pattern to check for a non-empty selection?
On Feb 19, 2010, at 7:15 AM, Jerry Krinock wrote: On 2010 Feb 19, at 03:02, Jean-Denis Muys wrote: I have tried bindings to selectedObjects using the model key count, as a non zero count is obviously compatible with the BOOL that the property expects. But this doesn't work: I get an error message: Cannot create BOOL from object () of class __NSArray0 It means that it wants a BOOL but the selectedObjects you're giving it is an array. Did you try the @count KVC operator? http://developer.apple.com/mac/library/documentation/cocoa/conceptual/KeyValueCoding/Concepts/ArrayOperators.html Using the model key count to an array property (selectedObjects) builds a new array containing the results of invoking valueForKey:@count to each element of selectedObjects, which isn't what you meant. 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: what is a bindings pattern to check for a non-empty selection?
I too have been wondering how others approach this issue. For a long time I used canRemove and eventually switched to using my own value transformer which does the heavy lifting for me. But it's quite tedious to include this value transformer in every project I write which uses bindings like this, so I've been looking for a built-in alternative. So now I'm wondering if selectedobjec...@count is a good alternative. Have yet to try it, but it looks viable. -Steven On Fri, Feb 19, 2010 at 8:27 AM, Ken Thomases k...@codeweavers.com wrote: On Feb 19, 2010, at 7:15 AM, Jerry Krinock wrote: On 2010 Feb 19, at 03:02, Jean-Denis Muys wrote: I have tried bindings to selectedObjects using the model key count, as a non zero count is obviously compatible with the BOOL that the property expects. But this doesn't work: I get an error message: Cannot create BOOL from object () of class __NSArray0 It means that it wants a BOOL but the selectedObjects you're giving it is an array. Did you try the @count KVC operator? http://developer.apple.com/mac/library/documentation/cocoa/conceptual/KeyValueCoding/Concepts/ArrayOperators.html Using the model key count to an array property (selectedObjects) builds a new array containing the results of invoking valueForKey:@count to each element of selectedObjects, which isn't what you meant. 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: http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com This email sent to steven.degu...@gmail.com -- Steven Degutis http://www.thoughtfultree.com/ http://www.degutis.org/ ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Help with creating CustomViews
It sounds a lot to me (and I could be wrong here) that you're trying to implement something along the lines of an ActiveX control as they were back when I used Visual Basic 5, in the sense that you want a control which is really a collection of other controls, and to be able to drag them around in IB and treat this collection as if they were a single control. While it is possible using IB Plugins, that's not really what IB's plugin system was intended for. This plugin system was meant more for control that are actually custom, such as a WebView object or PDFView or IKImageView or ABPeoplePickerView. (These are all custom classes which Apple has included into IB via its own default set of plugins.) This is to say, the plugin system is intended for actual subclasses of NSView or NSControl (or NSCell) which implement very specific and unique behavior, and where it's important (or at least desired by management) to be able to set their settings in IB during design-time. What you're doing can easily be accomplished in code, by having an NSViewController that points to your own XIB file, and by creating instances of this view controller and inserting its view into other views. This is the canonical way. Not only do you get more flexibility by doing it in code (and a lot less repetition in IB) but this method allows you to encapsulate another level of abstractness inside your NSViewController subclass, thus cleaning up your code (a lot). This is what more experienced Cocoa coders generally do instead of what you're trying to do. -Steven On Mon, Feb 15, 2010 at 9:19 PM, Jean-Henri Duteau duteaudes...@gmail.comwrote: Hi all, I'm a newcomer when it comes to Cocoa development. I have some good books and they discuss the possibility of CustomViews but the views they create aren't the type that I'm interested. I've scoured the web and haven't found exactly the help I need and I've tried the trial-and-error method and it hasn't worked. What I'm trying to do is the following: -I have a number of model objects, different instances of the same class. -I want to create a CustomView that would enable the display of these objects. -The CustomView is defined in its own NIB file. It consists of a bunch of NSTextField objects laid out in NSBox. -I then want to use that CustomView all over the place. :) But for starters, I'm trying to create a window with 10 instances of my CustomView. -I want to drop the CustomView in other NIB files and set up the actions/outlets/etc. The path that I took that seemed to give the best promise was: I created a CustomViewController (subclassing NSViewController) In MyDocument.init, I init the CustomViewController with my CustomView NIB file. In MyDocument.windowControllerDidLoadNib, I call viewController.view setFrame: and then windowController.window.contentView addSubView. That manages to get my CustomView to show up in the document's window. But that was done programatically and not in IB. Then I looked at the DragAround sample code on the Apple site. This seemed to be exactly give tips for exactly what I wanted, except that the DragAroundView draws itself, there is no NIB file for the view. If someone can point me to some sample code, that would be great. In the meantime, I'll keep trying. Jean Duteau ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com This email sent to steven.degu...@gmail.com -- Steven Degutis http://www.thoughtfultree.com/ http://www.degutis.org/ ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Determine smallest height of vertical scrollbar
I went ahead and filed an enhancement request on this one - rdar://7667092 On Feb 18, 2010, at 11:55 AM, Eric Gorr wrote: Other then creating a dummy NSScoller and incrementally decreasing it's height until usableParts returns 0, is there any easy way to determine what the minimum height of a vertical scrollbar should be so that usableParts will not return NSNoScrollerParts? What I need to be able to do is limit the height of my window based, in part, on whether or not a vertical scrollbar will have usable parts. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Open panel is permanently dead?
Hi, I'm having some problems with an open panel. I display the panel, allow the user to chose and image, and then do some work, which involves showing a sheet while the work is done. This all works wonderfully, until the user clicks the set texture button again, and my method is called again. The second time, for some reason, the open panel is never displayed. Can anyone tell what's going on here? I've added code below: - (IBAction)setTexture:(id)sender{ NSOpenPanel http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSOpenPanel.html *panel = [NSOpenPanel http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSOpenPanel.html openPanel]; [panel setCanChooseFiles:YES]; [panel setCanChooseDirectories:NO]; [panel setResolvesAliases:YES]; [panel setAllowsMultipleSelection:NO]; [panel setTitle:@Select Texture]; [panel setAllowedFileTypes:[NSArray http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html arrayWithObject:@png]]; [panel beginSheetModalForWindow:[delegate windowForSheet] completionHandler:^(NSInteger result) { if (result == NSFileHandlingPanelOKButton) { NSURL http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSURL.html *selection = [[panel URLs] objectAtIndex:0]; NSImage http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSImage.html *image = [[[NSImage http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSImage.html alloc] initWithContentsOfURL:selection] autorelease]; [self.item addObserver:self forKeyPath:@textureIsCompressed options:NSKeyValueObservingOptionNew context:nil]; self.item.texture = image; [panel close]; [NSApp beginSheet:compressingTexturePanel modalForWindow:[delegate windowForSheet] modalDelegate:self didEndSelector:@selector(compressionSheetDidEnd:) contextInfo:nil]; [compressingProgress startAnimation:self]; } }];} 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Open panel is permanently dead?
On Feb 19, 2010, at 6:17 AM, Tom Davie wrote: Hi, I'm having some problems with an open panel. I display the panel, allow the user to chose and image, and then do some work, which involves showing a sheet while the work is done. This all works wonderfully, until the user clicks the set texture button again, and my method is called again. The second time, for some reason, the open panel is never displayed. Can anyone tell what's going on here? I've added code below: SWAG here: check the value of isReleasedWhenClosed. If it's YES, that would explain the panel being dead after the first time. Consider using orderOut to dismiss the panel instead of close. Cheers, . . . . . . . .Henry - (IBAction)setTexture:(id)sender{ NSOpenPanel http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSOpenPanel.html *panel = [NSOpenPanel http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSOpenPanel.html openPanel]; [panel setCanChooseFiles:YES]; [panel setCanChooseDirectories:NO]; [panel setResolvesAliases:YES]; [panel setAllowsMultipleSelection:NO]; [panel setTitle:@Select Texture]; [panel setAllowedFileTypes:[NSArray http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSArray.html arrayWithObject:@png]]; [panel beginSheetModalForWindow:[delegate windowForSheet] completionHandler:^(NSInteger result) { if (result == NSFileHandlingPanelOKButton) { NSURL http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSURL.html *selection = [[panel URLs] objectAtIndex:0]; NSImage http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSImage.html *image = [[[NSImage http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSImage.html alloc] initWithContentsOfURL:selection] autorelease]; [self.item addObserver:self forKeyPath:@textureIsCompressed options:NSKeyValueObservingOptionNew context:nil]; self.item.texture = image; [panel close]; [NSApp beginSheet:compressingTexturePanel modalForWindow:[delegate windowForSheet] modalDelegate:self didEndSelector:@selector(compressionSheetDidEnd:) contextInfo:nil]; [compressingProgress startAnimation:self]; } }];} 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: http://lists.apple.com/mailman/options/cocoa-dev/appledeveloper%40trilithon.com This email sent to appledevelo...@trilithon.com = iPhone App Development and Developer Education . . . Visit www.nonatomic-retain.com Mac OSX Application Development, Plus a Great Deal More . . . Visit www.trilithon.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Uncaught exceptions not terminating my app
Just a quick update on this for anyone still interested. To the list of exceptions to explicitly ignore in your uncaught exception handler, include NSPortTimeoutExceptions. These happen (rarely) when the spell checking service is busy or slow to start up (I'm not sure which, it's happening on a customer's machine). There are also probably other cases, although we haven't seen any. Other than that, and a one-off crash on Tiger that actually looks like a Tiger bug, the scheme is working well, in the sense that one learns interesting things without inconveniencing users unduly. Paul Sanders. http://www.alpinesoft.co.uk - Original Message - From: Paul Sanders p.sand...@alpinesoft.co.uk To: cocoa-dev@lists.apple.com Sent: Wednesday, January 27, 2010 7:01 PM Subject: Re: Uncaught exceptions not terminating my app Here's the list of exceptions I silently ignore in my NSExceptionHandler delegate: --- NSString *nss_exception_name = [exception name]; NSString *nss_reason = [exception reason]; if ([nss_exception_name isEqualToString: NSAccessibilityException]) return YES; if ([nss_exception_name isEqualToString: NSInternalInconsistencyException]) { if (gIsTiger) // Happens on startup, apparently a Tiger bug { // __T (lockFocus sent to a view whose window is ) // __T (deferred and does not yet have a corresponding platform window) if ([nss_reason hasPrefix: @lockFocus sent to a view whose window is deferred]) return YES; } // Happens occasionally during testing (on 10.5.8), plus one crash reported in the field if ([nss_reason hasPrefix: @Invalid message sent to event \NSEvent: type=LMouseUp]) return YES; if ([nss_reason hasPrefix: @Invalid message sent to event \NSEvent: type=RMouseUp]) return YES; // Seen this once in the field: if ([nss_reason hasPrefix: @Failed to get KeyCode from EventRef]) return YES; } // Display bye-bye message to the user, maybe offer to save her work if U R feeling brave. * (int *) 1 = 0; ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Strange 'DrawTheMenu' crash
Has anyone ever experienced a crash like the one below? It is happening sporadically in the field (I have, I think, 5 crash logs, spread across all 3 major versions of OS X, i.e. 10.4, 10.5 and 10.6) but I have never seen it here. Examination of the object code reveals that NSCarbonMenuImpl+527 is a call to [NSMenu _enableItems]. All I have to work from is the crash log, but I'm as confident as one can ever be that our NSMenu object has not been released or corrupted. It is pretty much static for the life of the app. The only thing we do which might be a bit unusual is to call [NSApplication setMainMenu] whenever the app comes to the front. That's not actually necessary and I plan to change it, but I thought it worth mentioning. Any clues anybody? Many thanks, Paul Sanders http://www.alpinesoft.co.uk Date/Time: 2010-02-15 14:36:38.032 -0600 OS Version: Mac OS X 10.6.2 (10C540) Report Version: 6 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x7364618f Crashed Thread: 0 Dispatch queue: com.apple.main-thread Application Specific Information: objc_msgSend() selector name: respondsToSelector: Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 libobjc.A.dylib 0x94ca9ed7 objc_msgSend + 23 1 com.apple.AppKit 0x95b333a0 -[menu _carbonUpdateStatusEvent:handlerCallRef:] + 527 2 com.apple.AppKit 0x95b30f79 NSSLMMenuEventHandler + 404 3 com.apple.HIToolbox 0x9009ee29 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1567 4 com.apple.HIToolbox 0x9009e0f0 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 411 5 com.apple.HIToolbox 0x900c0981 SendEventToEventTarget + 52 6 com.apple.HIToolbox 0x900ece3b SendHICommandEvent(unsigned long, HICommand const*, unsigned long, unsigned long, unsigned char, void const*, OpaqueEventTargetRef*, OpaqueEventTargetRef*, OpaqueEventRef**) + 448 7 com.apple.HIToolbox 0x900ecc78 UpdateHICommandStatusWithCachedEvent + 66 8 com.apple.HIToolbox 0x9009a619 HIApplication::EventHandler(OpaqueEventHandlerCallRef*, OpaqueEventRef*, void*) + 1287 9 com.apple.HIToolbox 0x9009ee29 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1567 10 com.apple.HIToolbox 0x9009e0f0 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 411 11 com.apple.HIToolbox 0x900c0981 SendEventToEventTarget + 52 12 com.apple.HIToolbox 0x900ea735 SendMenuOpening(MenuSelectData*, MenuData*, double, unsigned long, __CFDictionary*, unsigned char, unsigned char*) + 826 13 com.apple.HIToolbox 0x902903b2 _SimulateMenuOpening + 75 14 com.apple.shortcut0x92a688c8 -[SCTGRLIndex indexCarbonMenu:withParentMenu:resultGRLs:isRootMenu:systemHelpMenu:withDepth:] + 871 15 com.apple.shortcut0x92a68476 -[SCTGRLIndex indexMenuBar:] + 192 16 com.apple.shortcut0x92a683ae -[SCTGRLIndex indexMenuBarDynamically] + 283 17 com.apple.shortcut0x92a2 SCTHelpMenuHandler + 326 18 com.apple.HIToolbox 0x9009ee29 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1567 19 com.apple.HIToolbox 0x9009e0f0 SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 411 20 com.apple.HIToolbox 0x9009df4f SendEventToEventTargetWithOptions + 58 21 com.apple.HIToolbox 0x900eac42 SendMenuPopulate(MenuData*, OpaqueEventTargetRef*, unsigned long, double, unsigned long, OpaqueEventRef*, unsigned char*) + 356 22 com.apple.HIToolbox 0x900ea505 SendMenuOpening(MenuSelectData*, MenuData*, double, unsigned long, __CFDictionary*, unsigned char, unsigned char*) + 266 23 com.apple.HIToolbox 0x900ea010 DrawTheMenu(MenuSelectData*, __CFArray**, unsigned char, unsigned char*) + 260 24 com.apple.HIToolbox 0x900e9dda MenuChanged(MenuSelectData*, unsigned char, unsigned char) + 467 25 com.apple.HIToolbox 0x900e8b55 TrackMenuCommon(MenuSelectData, unsigned char*) + 1481 26 com.apple.HIToolbox 0x900e1195 MenuSelectCore(MenuData*, Point, double, unsigned long, OpaqueMenuRef**, unsigned short*) + 315 27 com.apple.HIToolbox 0x900e09a9 _HandleMenuSelection2 + 465 28 com.apple.HIToolbox 0x900e07c7 _HandleMenuSelection + 53 29 com.apple.AppKit 0x95b2a4ba _NSHandleCarbonMenuEvent + 285 30 com.apple.AppKit 0x95aff076 _DPSNextEvent + 2304 31 com.apple.AppKit 0x95afe306 -[NSApplication
Customizing how errors are presented
I would like to customize how errors in controls like NSTextField are presented. The documentation for NSResponder recommends overriding -willPresentError: in order to customize error presentation. However, that doesn't let me customize *how* the error will be presented to the user. I am unhappy with the alerts because they interfere with the interaction by demanding immediate user attention. For NSTextFields, for example, I would like to experiment with presenting errors by changing the text field's text color, background color, or focus ring color and maybe showing an icon inside the text field, and maybe something else, too. Whatever invalid data should remain visible in the text field for later editing, and only valid data should be passed on to the model. Committing changes should be possible when no control has errors. What is the best way of achieving that? ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: super call in the middle of a block of code ..
Although it looks like your code is leaking a NSIndexPath each time through because you retain it on if (editing) and release it on if (!editing). On Feb 18, 2010, at 7:53 AM, Luke the Hiesterman wrote: This seems fine to me. Generally, when subclassing, the contract is that you must call super - there is nothing said about where in your method you do so. Luke On Feb 18, 2010, at 5:58 AM, Roland King wrote: I have this piece of code in my UITableViewController subclass (that is also my tableview delegate) -(void)setEditing:(BOOL)editing animated:(BOOL)animated { if( editing ) preEditPath = [ [ [ self tableView ] indexPathForSelectedRow ] retain ]; [ super setEditing:editing animated:animated ]; if( !editing ) { [ [ self tableView ] selectRowAtIndexPath:preEditPath animated:YES scrollPosition:UITableViewScrollPositionNone ]; [ preEditPath release ]; preEditPath = nil; } } The object here is to catch the current selection on the tableview when the table goes into edit mode (because when it does, the selection is nil'ed with no delegate call) and then restore it when the table comes out of edit mode. In the meantime I'm using the delegate calls which do exist to deal with the case where the selected row is moved or deleted so I restore the right thing. The super call is in the middle of the block because I've observed that it's that super call which removes the selection whether you are entering or exiting edit mode, so if I call it right at the start of the block, the selection is nil'ed before I cache it, if I call super at the end of the block, the super call deselects the selection I just put back. But having a super call in the middle of an overriden method seems wrong to me, and a bit fragile, and it relies on the observation that that's where the selection is nil'ed. Is this unusual, totally wrong or ok? ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: super call in the middle of a block of code ..
why would that leak it? Those calls are paired, a table enters editing mode, the variable is set and what it's set to is retained, when the table exits editing mode again the cached value is released and nil'ed. The variable is also released in dealloc (not shown here). I do not know of a case where setEditing is called with YES twice without an intervening setEditing:NO. On 20-Feb-2010, at 12:07 AM, Steve Christensen wrote: Although it looks like your code is leaking a NSIndexPath each time through because you retain it on if (editing) and release it on if (!editing). On Feb 18, 2010, at 7:53 AM, Luke the Hiesterman wrote: This seems fine to me. Generally, when subclassing, the contract is that you must call super - there is nothing said about where in your method you do so. Luke On Feb 18, 2010, at 5:58 AM, Roland King wrote: I have this piece of code in my UITableViewController subclass (that is also my tableview delegate) -(void)setEditing:(BOOL)editing animated:(BOOL)animated { if( editing ) preEditPath = [ [ [ self tableView ] indexPathForSelectedRow ] retain ]; [ super setEditing:editing animated:animated ]; if( !editing ) { [ [ self tableView ] selectRowAtIndexPath:preEditPath animated:YES scrollPosition:UITableViewScrollPositionNone ]; [ preEditPath release ]; preEditPath = nil; } } The object here is to catch the current selection on the tableview when the table goes into edit mode (because when it does, the selection is nil'ed with no delegate call) and then restore it when the table comes out of edit mode. In the meantime I'm using the delegate calls which do exist to deal with the case where the selected row is moved or deleted so I restore the right thing. The super call is in the middle of the block because I've observed that it's that super call which removes the selection whether you are entering or exiting edit mode, so if I call it right at the start of the block, the selection is nil'ed before I cache it, if I call super at the end of the block, the super call deselects the selection I just put back. But having a super call in the middle of an overriden method seems wrong to me, and a bit fragile, and it relies on the observation that that's where the selection is nil'ed. Is this unusual, totally wrong or ok? ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to detect if mouse on border of view
On Feb 18, 2010, at 8:44 PM, Mazen M. Abdel-Rahman wrote: I was wondering if there is a straight forward away to know if the mouse is on the border of a view? I know how to detect if the mouse enters a view area by using NSTrackingArea - but how can I tell if the mouse is on a border? I would like to replicate iCal's behavior where a user can modify an event on the calendar by clicking on the edge of the appt. rectangle and dragging it. Assuming you just care when the mouse clicks, you could test for it like this. - (void) mouseDown:(NSEvent*)theEvent { NSPoint localMouseLocation = [self convertPoint:[theEvent locationInWindow] fromView:nil]; NSRect nonBorderRect = NSInsetRect([self bounds], 4, 4); if (NSPointInRect(localMouseLocation, nonBorderRect)) { // click inside the non-border portion of the view } else { // click in the view's border } } ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
How to relayout content of NSTextView so that my tab characters are drawn with width of 4 characters
I'm working with an NSTextView and one of the requirements I have is that a tab character, '\t', shall have the same width as four spaces. So the text-content would look like this: - 1 tab - 4 spaces And this is how I accomplish this: // done when NSTextView first loaded and when // delegate's textDidBeginEditing gets called: (perhaps overkill, but is a work in progress). - (void)updateMyTextViewTextAttributes { NSMutableParagraphStyle* paragraphStyle = [[myTextView defaultParagraphStyle] mutableCopy]; if (paragraphStyle == nil) { paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; } float charWidth = [[myFont screenFontWithRenderingMode:NSFontDefaultRenderingMode] advancementForGlyph:(NSGlyph) ' '].width; [paragraphStyle setDefaultTabInterval:(charWidth * 4)]; [paragraphStyle setTabStops:[NSArray array]]; [myTextView setDefaultParagraphStyle:paragraphStyle]; NSMutableDictionary* typingAttributes = [[myTextView typingAttributes] mutableCopy]; [typingAttributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName]; [typingAttributes setObject:scriptFont forKey:NSFontAttributeName]; [myTextView setTypingAttributes:typingAttributes]; } This allows the appropriate layout to be shown with the initial text as well as keep the typing attributes the same. The problem is that the end-user can change the font. And when that happens, the sample text becomes misaligned. Much like the below: [smaller font] - 1 tab - 4 spaces [larger font] - 1 tab - 4 spaces I've tried calling myTextView's setNeedsDisplay:YES as I read that it ends up calling NSTextView's setNeedsDisplayInRect:avoidAdditionalLayout with a NO for the avoidAdditionalLayout parameter. This didn't change anything. I've tried calling my updateMyTextViewTextAttributes call when myTextView has the new myFont set. That doesn't change a thing. I've also tried telling the layoutManager of myTextView to ensureLayoutFOrTextContainer for the textContainer of myTextView. No change. At this point, I'm not sure what to try next. Any suggestions? Thanks in advance, Lyndsey Ferguson PS I've posted this to stackoverflow.com as well: http://stackoverflow.com/questions/2284150/how-to-relayout-content-of-nstextview-so-that-my-tab-characters-are-drawn-with-wi ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to relayout content of NSTextView so that my tab characters are drawn with width of 4 characters
My layout got messed up. Imagine that the - 1 tab is is tabbed in with the width of four spaces and that the - 4 spaces block lines up along with it. Also, imagine that: [smaller font] - 1 tab - 4 spaces has the - 1 tab offset to the right of the - 4 spaces block, and: [larger font] - 1 tab - 4 spaces has the - 1 tab offset to the left of the - 4 spaces block. Thanks, Lyndsey On Fri, Feb 19, 2010 at 12:03 PM, lyndsey.fergu...@gmail.com wrote: I'm working with an NSTextView and one of the requirements I have is that a tab character, '\t', shall have the same width as four spaces. So the text-content would look like this: - 1 tab - 4 spaces And this is how I accomplish this: // done when NSTextView first loaded and when // delegate's textDidBeginEditing gets called: (perhaps overkill, but is a work in progress). - (void)updateMyTextViewTextAttributes { NSMutableParagraphStyle* paragraphStyle = [[myTextView defaultParagraphStyle] mutableCopy]; if (paragraphStyle == nil) { paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; } float charWidth = [[myFont screenFontWithRenderingMode:NSFontDefaultRenderingMode] advancementForGlyph:(NSGlyph) ' '].width; [paragraphStyle setDefaultTabInterval:(charWidth * 4)]; [paragraphStyle setTabStops:[NSArray array]]; [myTextView setDefaultParagraphStyle:paragraphStyle]; NSMutableDictionary* typingAttributes = [[myTextView typingAttributes] mutableCopy]; [typingAttributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName]; [typingAttributes setObject:scriptFont forKey:NSFontAttributeName]; [myTextView setTypingAttributes:typingAttributes]; } This allows the appropriate layout to be shown with the initial text as well as keep the typing attributes the same. The problem is that the end-user can change the font. And when that happens, the sample text becomes misaligned. Much like the below: [smaller font] - 1 tab - 4 spaces [larger font] - 1 tab - 4 spaces I've tried calling myTextView's setNeedsDisplay:YES as I read that it ends up calling NSTextView's setNeedsDisplayInRect:avoidAdditionalLayout with a NO for the avoidAdditionalLayout parameter. This didn't change anything. I've tried calling my updateMyTextViewTextAttributes call when myTextView has the new myFont set. That doesn't change a thing. I've also tried telling the layoutManager of myTextView to ensureLayoutFOrTextContainer for the textContainer of myTextView. No change. At this point, I'm not sure what to try next. Any suggestions? Thanks in advance, Lyndsey Ferguson P.S. I've posted this to stackoverflow.com as well: http://stackoverflow.com/questions/2284150/how-to-relayout-content-of-nstextview-so-that-my-tab-characters-are-drawn-with-wi -- Lyndsey Ferguson ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: super call in the middle of a block of code ..
Oh, sorry, I was looking at the routine on its own. You're hanging onto preEditPath for the duration of the editing period and then releasing it when it's done. It's still early and I haven't had any coffee. :) On Feb 19, 2010, at 8:15 AM, Roland King wrote: why would that leak it? Those calls are paired, a table enters editing mode, the variable is set and what it's set to is retained, when the table exits editing mode again the cached value is released and nil'ed. The variable is also released in dealloc (not shown here). I do not know of a case where setEditing is called with YES twice without an intervening setEditing:NO. On 20-Feb-2010, at 12:07 AM, Steve Christensen wrote: Although it looks like your code is leaking a NSIndexPath each time through because you retain it on if (editing) and release it on if (!editing). On Feb 18, 2010, at 7:53 AM, Luke the Hiesterman wrote: This seems fine to me. Generally, when subclassing, the contract is that you must call super - there is nothing said about where in your method you do so. Luke On Feb 18, 2010, at 5:58 AM, Roland King wrote: I have this piece of code in my UITableViewController subclass (that is also my tableview delegate) -(void)setEditing:(BOOL)editing animated:(BOOL)animated { if( editing ) preEditPath = [ [ [ self tableView ] indexPathForSelectedRow ] retain ]; [ super setEditing:editing animated:animated ]; if( !editing ) { [ [ self tableView ] selectRowAtIndexPath:preEditPath animated:YES scrollPosition:UITableViewScrollPositionNone ]; [ preEditPath release ]; preEditPath = nil; } } The object here is to catch the current selection on the tableview when the table goes into edit mode (because when it does, the selection is nil'ed with no delegate call) and then restore it when the table comes out of edit mode. In the meantime I'm using the delegate calls which do exist to deal with the case where the selected row is moved or deleted so I restore the right thing. The super call is in the middle of the block because I've observed that it's that super call which removes the selection whether you are entering or exiting edit mode, so if I call it right at the start of the block, the selection is nil'ed before I cache it, if I call super at the end of the block, the super call deselects the selection I just put back. But having a super call in the middle of an overriden method seems wrong to me, and a bit fragile, and it relies on the observation that that's where the selection is nil'ed. Is this unusual, totally wrong or ok? ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about NSScrollView
If you review the documentation, it tells you how to show either the vertical or the horizontal scroller. On Feb 19, 2010, at 6:13 AM, Mario Kušnjer wrote: On 2010.02.19, at 11:43, Jack Carbaugh wrote: tell your NSScrollView to setAutoHidesScrollers:yes This should hide the scrollbars until needed. http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSScrollView_Class/Reference/Reference.html That's one of the solutions. But then I could also remove headerView and evade the problem in the first place. What would be solution if I want to have vertical scroller visible ? I'm thinking more in the way of somehow recalculating contentView area before it gets send to the NSClipView to be displayed. Correct ? Wrong? Thanks for suggestions. Mario Kušnjer mario.kusn...@sb.t-com.hr +385957051982 mariokusnjer (at) Skype = ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
selectItemWithObjectValue
I get this warning, but I never call these methods: 2010-02-19 09:56:29.975 Customize It[338:10b] *** -[NSComboBoxCell selectItemWithObjectValue:] should not be called when usesDataSource is set to YES 2010-02-19 09:56:29.976 Customize It[338:10b] *** -[NSComboBoxCell indexOfItemWithObjectValue:] should not be called when usesDataSource is set to YES I do call [self setStringValue:@Normal]; [self selectItemWithObjectValue:@Normal]; where self is a subclass of NSComboBox. According to the docs this is one way of setting a combo box value that works for both internal and external data sources. So, I am wondering why the warning ... I like to clear all warnings :) -db From the docs: And this code initializes the combo box’s text field to “Red” and selects it from the list if available. Note that this works for combo boxes with either internal or external data sources: [myComboBox setStringValue:@Red]; [myComboBox selectItemWithObjectValue:@Red];___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Customizing how errors are presented
On 2010 Feb 19, at 07:55, Dado Colussi wrote: I would like to customize how errors in controls like NSTextField are presented. The documentation for NSResponder recommends overriding -willPresentError: in order to customize error presentation. However, that doesn't let me customize *how* the error will be presented to the user. I am unhappy with the alerts because they interfere with the interaction by demanding immediate user attention. From Apple's Document-Based Applications Overview: If you ... don't want an error alert to be presented to the user, return an error object whose domain is NSCocoaErrorDomain and whose code is NSUserCancelledError. The Application Kit presents errors through the NSApplication implementations of the presentError: and presentError:modalForWindow:delegate:didPresentSelector:contextInfo: methods declared by NSResponder. Those implementations silently ignore errors whose domain is NSCocoaErrorDomain and whose code is NSUserCancelledError. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to relayout content of NSTextView so that my tab characters are drawn with width of 4 characters
On Feb 19, 2010, at 9:03 AM, lyndsey.fergu...@gmail.com wrote: I've tried calling my updateMyTextViewTextAttributes call when myTextView has the new myFont set. That doesn't change a thing. With updateMyTextViewTextAttributes as described, it will set the paragraph style for new text but won't change the paragraph style for existing text. What you would want to do would be to apply the new paragraph style to the existing text, by setting it as the value for NSParagraphStyleAttributeName on the text storage. To make this work well with the text view, you would probably want to surround this with calls to shouldChange/didChange methods--take a look at some of the samples for code examples of this sort of thing. Douglas Davidson ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Executing shell script with root privilege
Steven, You are right. I got my way. Regards, Cocoa.learner On Mon, Feb 15, 2010 at 9:01 PM, Steven Degutis steven.degu...@gmail.comwrote: Essentially you need to use the Security.framework API which you were already using in the beginning. You're already heading in the right direction. If you continue to read the docs on it, you'll get your sample code working; they're pretty thorough docs I believe. -Steven On Mon, Feb 15, 2010 at 1:48 AM, cocoa learner cocoa.lear...@gmail.comwrote: Ok let me put my problem in simple words - I have a cocoa app and I want to launch a shell script which has to do some task with root privilege. How can I do it??? Regards, Cocoa.learner On Mon, Feb 15, 2010 at 1:49 AM, Nick Zitzmann n...@chronosnet.com wrote: On Feb 13, 2010, at 11:05 PM, cocoa learner wrote: And permission of this script is - -rwx-- 1 root wheel 536 Feb 14 10:51 /Users/test/myScript When I am executing the app launchScript is returning me TRUE but my script is not getting executed. I am totally lost, have no clue why it's happening like this. Does any body know why this script is not getting executed? Am I doing any thing wrong? Yes and yes. You set your script's permissions to 700 root/wheel, which means that you don't have permission to run the script. AEWP() executes tasks with root privileges, but it doesn't execute them _as_ root. If you need to do that, then you must use a wrapper that sets the uid to root. Check the archives for more information. It might be easier, though, to set the permissions to 755 instead, and put in a check for root privileges. And if that still doesn't work, then you might need to execute the shell as the task, and point the shell to the script, but I'm pretty sure you just have the permissions set incorrectly. Nick Zitzmann http://www.chronosnet.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: http://lists.apple.com/mailman/options/cocoa-dev/steven.degutis%40gmail.com This email sent to steven.degu...@gmail.com -- Steven Degutis http://www.thoughtfultree.com/ http://www.degutis.org/ ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: super call in the middle of a block of code ..
On Fri, Feb 19, 2010 at 8:15 AM, Roland King r...@rols.org wrote: why would that leak it? Those calls are paired, a table enters editing mode, the variable is set and what it's set to is retained, when the table exits editing mode again the cached value is released and nil'ed. The variable is also released in dealloc (not shown here). I do not know of a case where setEditing is called with YES twice without an intervening setEditing:NO. Just because you don't know of a case doesn't mean that you shouldn't be prepared for it. If I were you, I would do something like: -(void)setEditing:(BOOL)editing animated:(BOOL)animated { if(editing) { [preEditPath release]; preEditPath = [[[self tableView] indexPathForSelectedRow] retain]; } [super setEditing: editing animated: animated]; if(!editing preEditPath) { [[self tableView] selectRowAtIndexPath: preEditPath animated: YES scrollPosition: UITableViewScrollPositionNone]; [preEditPath release ]; preEditPath = nil; } } That is, release preEditPath in the editing case before setting it, to avoid a leak in the case you are called twice with a value of YES, as well as avoid passing a nil preEditPath to -selectRowAtIndexPath:animated:scrollPosition: in the case that you are called twice with a value of NO. -- Clark S. Cox III clarkc...@gmail.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to relayout content of NSTextView so that my tab characters are drawn with width of 4 characters
- (void)updateMyTextViewTextAttributes { NSMutableParagraphStyle* paragraphStyle = [[myTextView defaultParagraphStyle] mutableCopy]; if (paragraphStyle == nil) { paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; } float charWidth = [[myFont screenFontWithRenderingMode:NSFontDefaultRenderingMode] advancementForGlyph:(NSGlyph) ' '].width; [paragraphStyle setDefaultTabInterval:(charWidth * 4)]; [paragraphStyle setTabStops:[NSArray array]]; [myTextView setDefaultParagraphStyle:paragraphStyle]; NSMutableDictionary* typingAttributes = [[myTextView typingAttributes] mutableCopy]; [typingAttributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName]; [typingAttributes setObject:scriptFont forKey:NSFontAttributeName]; [myTextView setTypingAttributes:typingAttributes]; NSRange rangeOfChange = NSMakeRange(0, [[myTextView string] length]); [myTextView shouldChangeTextInRange:rangeOfChange replacementString:nil]; [[myTextView textStorage] setAttributes:typingAttributes range:rangeOfChange]; [myTextView didChangeText]; } On Fri, Feb 19, 2010 at 12:35 PM, Douglas Davidson ddavi...@apple.com wrote: On Feb 19, 2010, at 9:03 AM, lyndsey.fergu...@gmail.com wrote: I've tried calling my updateMyTextViewTextAttributes call when myTextView has the new myFont set. That doesn't change a thing. With updateMyTextViewTextAttributes as described, it will set the paragraph style for new text but won't change the paragraph style for existing text. What you would want to do would be to apply the new paragraph style to the existing text, by setting it as the value for NSParagraphStyleAttributeName on the text storage. To make this work well with the text view, you would probably want to surround this with calls to shouldChange/didChange methods--take a look at some of the samples for code examples of this sort of thing. Douglas Davidson -- Lyndsey Ferguson ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Real-Time Validation in a NSTextField.
On 2/18/2010 2:18 PM, Abhinay Kartik Reddyreddy wrote: I was wondering if there is any alternative / better approach for validating text in a textfield?? I've done this by writing a custom subclass of NSFormatter that overrides isPartialStringValid:newEditingString:errorDescription:. -- James W. Walker, Innoventive Software LLC http://www.frameforge3d.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableColumn's 'fontSize' Binding: Just Doesn't Work?
On 2010 Feb 18, at 17:32, Keary Suska wrote: you could just use the willDisplayCell delegate method? And indeed I did and it works. Thank you, Keary. I wasn't aware of that method. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
strange crash in NSAccessibility
Hello All, I have a strange crash happening while trying load an open file window/sheet (NSOpenPanel). I've got a simple AppController class, which is set as the Application's delegate. This is all there is to the controller, at this point: #import AppController.h @implementation AppController - (void) openPanelDidEnd:(NSOpenPanel*)openPanel returnCode:(int)returnCode contextInfo:(void*)x { if(returnCode == NSOKButton) { NSString* path = [openPanel filename]; // do smart stuff here... NSLog(@Tried to import midi file %@, path); } } - (IBAction) showMIDIImportPanel:(id)sender { NSOpenPanel* panel = [NSOpenPanel openPanel]; [panel beginSheetForDirectory:nil file:nil types:[NSSound soundUnfilteredTypes] modalForWindow:[NSApp mainWindow] modalDelegate:self didEndSelector:@selector(openPanelDidEnd:returnCode:contextInfo:) contextInfo:NULL]; } @end I actually have no idea why the NSAccessibility stuff is coming up, and the docs didn't shed much light for me. The bt is below. It loads the sheet, then lists the files in the selected directory, then crashes. It works fine if I disable access for assistive devices on the system, but is there some legit way around this? Some exception I should be handling? This is the first time I've run into any accessibility stuff. Also, just in case anyone knows, when it does work (with assistive devices disabled), it doesn't actually recognize midi files. Does anyone know what, if not [NSSound soundUnfilteredTypes], what types I would indicate for opening midi files? Thanks in advance for any thoughts. J. #0 0x97c54a16 in -[NSException raise] () #1 0x931ac55c in NSAccessibilityAttributeValue () #2 0x933c443f in CopyAppKitUIElementAttributeValueNoCatch () #3 0x933c69d7 in CopyAttributeValue () #4 0x90461ad3 in _AXXMIGCopyAttributeValue () #5 0x9046bb96 in _XCopyAttributeValue () #6 0x9043dc39 in mshMIGPerform () #7 0x97b758db in __CFRunLoopRun () #8 0x97b73864 in CFRunLoopRunSpecific () #9 0x97b73691 in CFRunLoopRunInMode () #10 0x91a39f0c in RunCurrentEventLoopInMode () #11 0x91a39cc3 in ReceiveNextEventCommon () #12 0x91a39b48 in BlockUntilNextEventMatchingListInMode () #13 0x93160ac5 in _DPSNextEvent () #14 0x93160306 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] () #15 0x9312249f in -[NSApplication run] () #16 0x9311a535 in NSApplicationMain () #17 0x2828 in main () at main.m:13 --- James B Maxwell Composer/Doctoral Student School for the Contemporary Arts (SCA) School for Interactive Arts + Technology (SIAT) Simon Fraser University jbmaxw...@rubato-music.com jbmax...@sfu.ca ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: strange crash in NSAccessibility
On Feb 19, 2010, at 10:41 AM, James Maxwell wrote: I have a strange crash happening while trying load an open file window/sheet (NSOpenPanel). I've got a simple AppController class, which is set as the Application's delegate. This is all there is to the controller, at this point: I actually have no idea why the NSAccessibility stuff is coming up, and the docs didn't shed much light for me. The bt is below. It loads the sheet, then lists the files in the selected directory, then crashes. It works fine if I disable access for assistive devices on the system, but is there some legit way around this? Some exception I should be handling? This is the first time I've run into any accessibility stuff. #0 0x97c54a16 in -[NSException raise] () #1 0x931ac55c in NSAccessibilityAttributeValue () #2 0x933c443f in CopyAppKitUIElementAttributeValueNoCatch () #3 0x933c69d7 in CopyAttributeValue () #4 0x90461ad3 in _AXXMIGCopyAttributeValue () #5 0x9046bb96 in _XCopyAttributeValue () #6 0x9043dc39 in mshMIGPerform () #7 0x97b758db in __CFRunLoopRun () #8 0x97b73864 in CFRunLoopRunSpecific () #9 0x97b73691 in CFRunLoopRunInMode () #10 0x91a39f0c in RunCurrentEventLoopInMode () #11 0x91a39cc3 in ReceiveNextEventCommon () #12 0x91a39b48 in BlockUntilNextEventMatchingListInMode () #13 0x93160ac5 in _DPSNextEvent () #14 0x93160306 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] () #15 0x9312249f in -[NSApplication run] () #16 0x9311a535 in NSApplicationMain () #17 0x2828 in main () at main.m:13 This sort of backtrace is what happens when the assistive device machinery interrogates your process. If you don't write any accessibility code then assistive devices might not work well with your program, but it's not expected to crash. The first thing to do is to look in the console for an error message printed by that exception. My guess is that you have a memory error elsewhere, and the exception is unrecognized selector because your memory error mangled the accessibility data structures. If that's the case then the Zombie Instrument should help find the bug. -- Greg Parker gpar...@apple.com Runtime Wrangler ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: strange crash in NSAccessibility
okay, thanks Greg. Good to know that assistive devices isn't supposed to gate crash just any old cocoa party! I'll look for the memory bug. cheers, J. On 2010-02-19, at 10:53 AM, Greg Parker wrote: On Feb 19, 2010, at 10:41 AM, James Maxwell wrote: I have a strange crash happening while trying load an open file window/sheet (NSOpenPanel). I've got a simple AppController class, which is set as the Application's delegate. This is all there is to the controller, at this point: I actually have no idea why the NSAccessibility stuff is coming up, and the docs didn't shed much light for me. The bt is below. It loads the sheet, then lists the files in the selected directory, then crashes. It works fine if I disable access for assistive devices on the system, but is there some legit way around this? Some exception I should be handling? This is the first time I've run into any accessibility stuff. #0 0x97c54a16 in -[NSException raise] () #1 0x931ac55c in NSAccessibilityAttributeValue () #2 0x933c443f in CopyAppKitUIElementAttributeValueNoCatch () #3 0x933c69d7 in CopyAttributeValue () #4 0x90461ad3 in _AXXMIGCopyAttributeValue () #5 0x9046bb96 in _XCopyAttributeValue () #6 0x9043dc39 in mshMIGPerform () #7 0x97b758db in __CFRunLoopRun () #8 0x97b73864 in CFRunLoopRunSpecific () #9 0x97b73691 in CFRunLoopRunInMode () #10 0x91a39f0c in RunCurrentEventLoopInMode () #11 0x91a39cc3 in ReceiveNextEventCommon () #12 0x91a39b48 in BlockUntilNextEventMatchingListInMode () #13 0x93160ac5 in _DPSNextEvent () #14 0x93160306 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] () #15 0x9312249f in -[NSApplication run] () #16 0x9311a535 in NSApplicationMain () #17 0x2828 in main () at main.m:13 This sort of backtrace is what happens when the assistive device machinery interrogates your process. If you don't write any accessibility code then assistive devices might not work well with your program, but it's not expected to crash. The first thing to do is to look in the console for an error message printed by that exception. My guess is that you have a memory error elsewhere, and the exception is unrecognized selector because your memory error mangled the accessibility data structures. If that's the case then the Zombie Instrument should help find the bug. -- Greg Parker gpar...@apple.com Runtime Wrangler James B Maxwell Composer/Doctoral Student School for the Contemporary Arts (SCA) School for Interactive Arts + Technology (SIAT) Simon Fraser University jbmaxw...@rubato-music.com jbmax...@sfu.ca ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: setAction:@selector is not working ?
i'm completely baffled by this. does anyone have a hint? i'm going to do a popup menu i run thru all the items and call [myMenuItem setAction:@selector(myFunction:)]; upon first run, my myFunction never gets called with the result of the menu item pick. but then, it works 100% of the time *after* i switch out then back into my app whaaa?? does anyone have an idea about 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: setAction:@selector is not working ?
On Feb 19, 2010, at 11:31 AM, David M. Cotter wrote: i'm completely baffled by this. does anyone have a hint? i'm going to do a popup menu i run thru all the items and call [myMenuItem setAction:@selector(myFunction:)]; Where is that line of code? Are you sure it's getting called on the first run? Are you sure that 'myMenuItem' is non-nil? Try putting in some breakpoints or NSLog calls to make sure. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: setAction:@selector is not working ?
just before the line of code that pops up the menu, i iterate over all the items so yes, i am absolutely sure it is getting called and i am absolutely sure that myMenuItem is non null i'm just wondering if there is something which pre-empts my code, telling the menu item to NOT call the action selector. what could *possibly* intervene here? On Feb 19, 2010, at 11:38 AM, Jens Alfke wrote: On Feb 19, 2010, at 11:31 AM, David M. Cotter wrote: i'm completely baffled by this. does anyone have a hint? i'm going to do a popup menu i run thru all the items and call [myMenuItem setAction:@selector(myFunction:)]; Where is that line of code? Are you sure it's getting called on the first run? Are you sure that 'myMenuItem' is non-nil? Try putting in some breakpoints or NSLog calls to make sure. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: setAction:@selector is not working ?
I would try and reset the target just after setting the action: [myMenuItem setAction:@selector(myFunction:)]; [myMenuItem setTarget:self]; I remember a long time ago I had a problem where if I reset the item's action, it would set the target to nil for some reason. So in practice I usually reset the target even if it's the same. Not sure if this is your issue though. On Feb 19, 2010, at 12:43 PM, David M. Cotter wrote: just before the line of code that pops up the menu, i iterate over all the items so yes, i am absolutely sure it is getting called and i am absolutely sure that myMenuItem is non null i'm just wondering if there is something which pre-empts my code, telling the menu item to NOT call the action selector. what could *possibly* intervene here? ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: setAction:@selector is not working ?
On Feb 19, 2010, at 2:43 PM, David M. Cotter wrote: just before the line of code that pops up the menu, i iterate over all the items so yes, i am absolutely sure it is getting called and i am absolutely sure that myMenuItem is non null Posting you code is wildly more helpful than describing it. Also, are you absolutely sure because you've reasoned about your code, or are you absolutely sure because you've set a breakpoint and you've actually *seen* that all is well (i.e. the item exists, the target and action are what you expected)? If you haven't done the latter, you should not be absolutely sure. Hank ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: setAction:@selector is not working ?
good tip, but no luck. same problem. myFunction is never called when i pick an item :( On Feb 19, 2010, at 11:50 AM, Michael Vannorsdel wrote: I would try and reset the target just after setting the action: [myMenuItem setAction:@selector(myFunction:)]; [myMenuItem setTarget:self]; I remember a long time ago I had a problem where if I reset the item's action, it would set the target to nil for some reason. So in practice I usually reset the target even if it's the same. Not sure if this is your issue though. On Feb 19, 2010, at 12:43 PM, David M. Cotter wrote: just before the line of code that pops up the menu, i iterate over all the items so yes, i am absolutely sure it is getting called and i am absolutely sure that myMenuItem is non null i'm just wondering if there is something which pre-empts my code, telling the menu item to NOT call the action selector. what could *possibly* intervene here? ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Appropriate -setWantsLayer: timing
On Wed, 17 Feb 2010 17:07:54 -1000, Dave Keck davek...@gmail.com said: Maybe I'm misunderstanding, but I'm wondering, why not put everything into a single method and call that method from both initWithFrame and awakeFromNib? One and only one of these will be called (depending whether you are instantiating in code or in a nib), so your single method will be called exactly once and you're off to the races. m. This isn't true for 10.5; both -initWithFrame: and -awakeFromNib are called if the view was instantiated via the NIB machinery. I suspect 10.6 is no different. OK, but in that case I would use a flag to make sure that my single method is called no more than once. I don't know whether this applies to the OP's actual use case; I'm just saying, when I am not sure which of several routines will be called or in what order and I want to make sure a certain thing happens, I just factor out that certain thing. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: setAction:@selector is not working ?
yes i've set a breakpoint and watched. in fact the values are the same before and after (indicating it was ALREADY set up correctly note the code below is called JUST before the call to popup the menu i only put that extra AE_OS_MAC stuff there to prove again that it is set correctly in reality it is set ahead of time, when the menu is constructed but either way, it fails until i switch out then back in. voidSetMenuCommands(dvaui::utility::OS_Menu *ioMenuP, short startIndexS) { dvaui::utility::OS_Menu::MenuID menuID(GetMenuID(*ioMenuP)); dvaui::utility::OS_Menu::MenuItemID maxS(ioMenuP-Size()); #ifdef AE_OS_MAC dvaui::ui::PlatformMenu platMenu(dvaui::utility::GetPlatformMenu(*ioMenuP)); #endif for (dvaui::utility::OS_Menu::MenuItemID itemIndexS = startIndexS; itemIndexS maxS; ++itemIndexS) { dvaui::utility::OS_Menu::MenuItemID itemID = ae_menu_utils::CreateMenuCommand(menuID, itemIndexS + 1); ioMenuP-SetItemID(itemIndexS, itemID); #ifdef AE_OS_MAC NSMenuItem* nsMenuItem([platMenu itemAtIndex: itemIndexS]); DVAMacMenuItem* dvaItem((DVAMacMenuItem *)nsMenuItem); [dvaItem setAction:@selector(dispatchMenuSelection:)]; [dvaItem setTarget: dvaItem]; [dvaItem setEnabled: YES]; #endif if (startIndexS == 0) { dvaui::utility::OS_MenuSharedPtr heirMenu(ioMenuP-GetItemSubMenu(itemIndexS)); if (heirMenu.get()) { SetMenuCommands(heirMenu.get(), notifyByPosB); } } } } On Feb 19, 2010, at 12:11 PM, Hank Heijink (Mailinglists) wrote: On Feb 19, 2010, at 2:43 PM, David M. Cotter wrote: just before the line of code that pops up the menu, i iterate over all the items so yes, i am absolutely sure it is getting called and i am absolutely sure that myMenuItem is non null Posting you code is wildly more helpful than describing it. Also, are you absolutely sure because you've reasoned about your code, or are you absolutely sure because you've set a breakpoint and you've actually *seen* that all is well (i.e. the item exists, the target and action are what you expected)? If you haven't done the latter, you should not be absolutely sure. Hank ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: selectItemWithObjectValue
On Fri, Feb 19, 2010 at 9:24 AM, David Blanton aired...@tularosa.net wrote: I get this warning, but I never call these methods: 2010-02-19 09:56:29.975 Customize It[338:10b] *** -[NSComboBoxCell selectItemWithObjectValue:] should not be called when usesDataSource is set to YES I do call [self selectItemWithObjectValue:@Normal]; You contradict yourself. ;-) --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSData as value in NSManagedObject
I've put a small NSXMLDocument into a Core Data binary property like this: code: NSManagedObject *object = /* ... */ NSXMLDocument *xmlDoc = /* ... */ [object setValue:[xmlDoc XMLData] forKey:@xml]; When I go to retrieve it, it's wrapped in an array: (gdb) print-object [object valueForKey:@xml] NSCFArray 0x12c6460( 3c3f786d 6c207665 7273696f 6e3d2231 2e302220 656e636f 64696e67 3d225554 462d3822 3f3e3c6a 6e6c7020 73706563 3d22312e 302b2220 636f6465 62617365 3d226874 74703a2f 2f77 ...etc... So I end up having to use lastObject to get the actual data: code: NSData *xmlData = (NSData *)[[object valueForKey:@xml] lastObject]; NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithData:xmlData options:NSXMLDocumentTidyXML error:nil]; If I don't use lastObject, I get an exception: 2010-02-17 20:46:47.590 AO[7954:813] *** -[NSCFArray length]: unrecognized selector sent to instance 0x1371170 I can't find anything in the docs for NSManagedObject or NSData that would explain this, where do I look? Regards, Mikkel ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Hillegass printing challenge
Hi Folks May I ask about an issue I am having adding page numbers to a print out. Can I just jump in on this thread and ask where I can find info about printing a document like an invoice, where there is a header and then a list of invoice lines that is possibly longer than one page? Regards Joanna -- Joanna Carter Carter Consulting___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: what is a bindings pattern to check for a non-empty selection?
Le 19 févr. 2010 à 11:02, Jean-Denis Muys a écrit : I am looking for a way to enable a button in my window only if some selection has been made in the data. Currently the data is shown in a table view and is handled through an NSArrayController. I am trying to bind the button's Enabled property to the ArrayController so that I get whether something is selected (multiple selections allowed). I bind the enabled property to the selection but using the NSIsNotNil value transformer. Joanna -- Joanna Carter Carter Consulting ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: selectItemWithObjectValue
Not really, as I call selectWithObjectValue on an NSComboBox and the warning is on an NSComboboxCell but so what , I am doing just what the docs say and I get the warning ... that is the essence of the question On Feb 19, 2010, at 1:48 PM, Kyle Sluder wrote: On Fri, Feb 19, 2010 at 9:24 AM, David Blanton aired...@tularosa.net wrote: I get this warning, but I never call these methods: 2010-02-19 09:56:29.975 Customize It[338:10b] *** -[NSComboBoxCell selectItemWithObjectValue:] should not be called when usesDataSource is set to YES I do call [self selectItemWithObjectValue:@Normal]; You contradict yourself. ;-) --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView with PopUpButtonCell column with different content per row
On 2/18/10 4:13 PM, Jerry Krinock said: Quincey's answer is excellent, and abstract. Let me give you a concrete example from one of my projects. Presumably your table is bound to an array controller whose contentSet or contentArray is bound to a collection of Foo objects in your data model. Table Column Bindings for OS Version column: Content: Bind to: FooArrayController Controller Key: arrangedObjects Model Key Path: osVersionChoices Content Values: Bind to: FooArrayController Controller Key: arrangedObjects Model Key Path: osVersionChoices.osVersionDisplayName Selected Object: Bind to: FooArrayController Controller Key: arrangedObjects Model Key Path: osVersion Jerry, Thanks for this example. I've used this technique elsewhere and like it too, but alas as soon as you want menu separators in the popup this no longer works. Unless you are aware of some way... In my case currently, I need several separators and also an 'other...' item that brings up an open panel. I'm going to investigate menuNeedsUpdate: a bit... Thanks all, -- 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Overriding NSPopUpButton
Hello. Is it possible to give a different color to the popupbutton? not the default one? will overriding NSPopUpButtonCell make the job? or are there any other aspects to take into mind when doing it? Thanks Gustavo___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to detect if mouse on border of view
Thanks everyone for your help on this. I wanted to know if the mouse was on the border area prior to the mouse down event to determine if the mouse icon should change as the mouse hovers over the border. Is there a way to do this without a mouseMoved event? Thanks, Mazen Abdel-Rahman -- Message: 11 Date: Thu, 18 Feb 2010 21:44:27 -0700 From: Mazen M. Abdel-Rahman mazen.m.abdelrah...@me.com Subject: How to detect if mouse on border of view To: cocoa-dev@lists.apple.com Message-ID: af901566-3187-4949-be67-6e3a70377...@me.com Content-Type: text/plain; charset=us-ascii Hi All, I was wondering if there is a straight forward away to know if the mouse is on the border of a view? I know how to detect if the mouse enters a view area by using NSTrackingArea - but how can I tell if the mouse is on a border? I would like to replicate iCal's behavior where a user can modify an event on the calendar by clicking on the edge of the appt. rectangle and dragging it. Thanks, Mazen -- Message: 12 Date: Fri, 19 Feb 2010 15:53:43 +1100 From: Graham Cox graham@bigpond.com Subject: Re: How to detect if mouse on border of view To: Mazen M. Abdel-Rahman mazen.m.abdelrah...@me.com Cc: cocoa-dev@lists.apple.com Message-ID: 7c4ab8b0-df1c-4d77-865f-fefda7d5e...@bigpond.com Content-Type: text/plain; charset=us-ascii On 19/02/2010, at 3:44 PM, Mazen M. Abdel-Rahman wrote: I was wondering if there is a straight forward away to know if the mouse is on the border of a view? I know how to detect if the mouse enters a view area by using NSTrackingArea - but how can I tell if the mouse is on a border? I would like to replicate iCal's behavior where a user can modify an event on the calendar by clicking on the edge of the appt. rectangle and dragging it. The border of a view doesn't really exist - it's infinitely narrow. What you really want is to detect that the mouse is inside the view but within a pixel or two of the edge. That is easy to work out by comparing the mouse point against the bounds to whatever degree of precision you want (I'd suggest not making it too precise, as it will be hard to hit - 4 pixels minimum is probably OK). --Graham -- Message: 13 Date: Thu, 18 Feb 2010 20:55:08 -0800 From: Jens Alfke j...@mooseyard.com Subject: Re: How to detect if mouse on border of view To: Mazen M. Abdel-Rahman mazen.m.abdelrah...@me.com Cc: cocoa-dev@lists.apple.com Message-ID: 64436a96-d241-409f-97cf-545ee9c52...@mooseyard.com Content-Type: text/plain; charset=windows-1252 On Feb 18, 2010, at 8:44 PM, Mazen M. Abdel-Rahman wrote: I was wondering if there is a straight forward away to know if the mouse is on the border of a view? I know how to detect if the mouse enters a view area by using NSTrackingArea - but how can I tell if the mouse is on a border? I would like to replicate iCal's behavior where a user can modify an event on the calendar by clicking on the edge of the appt. rectangle and dragging it. In your mouseDown: method, compare the coordinates against the edges of the view's bounds. Or is there a reason you need to know before the mouse-down occurs? ˜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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to detect if mouse on border of view
Read up on NSView's addCursorRect:cursor: method. _murat On Feb 19, 2010, at 1:36 PM, Mazen M. Abdel-Rahman wrote: Thanks everyone for your help on this. I wanted to know if the mouse was on the border area prior to the mouse down event to determine if the mouse icon should change as the mouse hovers over the border. Is there a way to do this without a mouseMoved event? Thanks, Mazen Abdel-Rahman -- Message: 11 Date: Thu, 18 Feb 2010 21:44:27 -0700 From: Mazen M. Abdel-Rahman mazen.m.abdelrah...@me.com Subject: How to detect if mouse on border of view To: cocoa-dev@lists.apple.com Message-ID: af901566-3187-4949-be67-6e3a70377...@me.com Content-Type: text/plain; charset=us-ascii Hi All, I was wondering if there is a straight forward away to know if the mouse is on the border of a view? I know how to detect if the mouse enters a view area by using NSTrackingArea - but how can I tell if the mouse is on a border? I would like to replicate iCal's behavior where a user can modify an event on the calendar by clicking on the edge of the appt. rectangle and dragging it. Thanks, Mazen -- Message: 12 Date: Fri, 19 Feb 2010 15:53:43 +1100 From: Graham Cox graham@bigpond.com Subject: Re: How to detect if mouse on border of view To: Mazen M. Abdel-Rahman mazen.m.abdelrah...@me.com Cc: cocoa-dev@lists.apple.com Message-ID: 7c4ab8b0-df1c-4d77-865f-fefda7d5e...@bigpond.com Content-Type: text/plain; charset=us-ascii On 19/02/2010, at 3:44 PM, Mazen M. Abdel-Rahman wrote: I was wondering if there is a straight forward away to know if the mouse is on the border of a view? I know how to detect if the mouse enters a view area by using NSTrackingArea - but how can I tell if the mouse is on a border? I would like to replicate iCal's behavior where a user can modify an event on the calendar by clicking on the edge of the appt. rectangle and dragging it. The border of a view doesn't really exist - it's infinitely narrow. What you really want is to detect that the mouse is inside the view but within a pixel or two of the edge. That is easy to work out by comparing the mouse point against the bounds to whatever degree of precision you want (I'd suggest not making it too precise, as it will be hard to hit - 4 pixels minimum is probably OK). --Graham -- Message: 13 Date: Thu, 18 Feb 2010 20:55:08 -0800 From: Jens Alfke j...@mooseyard.com Subject: Re: How to detect if mouse on border of view To: Mazen M. Abdel-Rahman mazen.m.abdelrah...@me.com Cc: cocoa-dev@lists.apple.com Message-ID: 64436a96-d241-409f-97cf-545ee9c52...@mooseyard.com Content-Type: text/plain; charset=windows-1252 On Feb 18, 2010, at 8:44 PM, Mazen M. Abdel-Rahman wrote: I was wondering if there is a straight forward away to know if the mouse is on the border of a view? I know how to detect if the mouse enters a view area by using NSTrackingArea - but how can I tell if the mouse is on a border? I would like to replicate iCal's behavior where a user can modify an event on the calendar by clicking on the edge of the appt. rectangle and dragging it. In your mouseDown: method, compare the coordinates against the edges of the view's bounds. Or is there a reason you need to know before the mouse-down occurs? ˜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: http://lists.apple.com/mailman/options/cocoa-dev/murat%40pixar.com This email sent to mu...@pixar.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: selectItemWithObjectValue
On Fri, Feb 19, 2010 at 1:08 PM, David Blanton aired...@tularosa.net wrote: Not really, as I call selectWithObjectValue on an NSComboBox and the warning is on an NSComboboxCell You are aware that many (most?) control methods are actually just cover methods for their underlying cells? The Control and Cell Programming Topics for Cocoa guide has more information: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ControlCell/ControlCell.html but so what , I am doing just what the docs say and I get the warning ... that is the essence of the question The NSComboBoxCell documentation disagrees with the documentation you've referenced. You should file a bug on the documentation. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Overriding NSPopUpButton
On Fri, Feb 19, 2010 at 1:31 PM, Gustavo Pizano gustavxcodepic...@gmail.com wrote: Is it possible to give a different color to the popupbutton? not the default one? will overriding NSPopUpButtonCell make the job? or are there any other aspects to take into mind when doing it? You would have to do all the drawing yourself. AppKit is not skinnable (and Mac users prefer it that way). --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
some advice on asynchronous control please
Hi All, I have a situation where I am using a 3rd party library to manage content on their service. When I delete an entry the method requires a call back all good. Now I need to wait for that call back to be called to know if it was successful or not. In the call back I can set a boolean to indicate success or not but waiting for that to be set is my issue. What is the right way to wait for it? I think while(!done) { [NSThread sleepForTimeInterval:1]; } Just blocks the main thread which is not what I want at all as this also blocks the run loop also. Can anyone give me some guidance on the best practice for this situation? Regards Damien___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: some advice on asynchronous control please
On Feb 19, 2010, at 2:06 PM, Damien Cooke wrote: I have a situation where I am using a 3rd party library to manage content on their service. When I delete an entry the method requires a call back all good. Now I need to wait for that call back to be called to know if it was successful or not. In the call back I can set a boolean to indicate success or not but waiting for that to be set is my issue. What is the right way to wait for it? You'll have to return back to the event loop / runloop after calling the delete-entry function. That lets the UI remain responsive. Then your callback function can call into whatever code you have that should run after the operation completes. —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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Appropriate -setWantsLayer: timing
On 19 Feb 2010, at 03:50, Scott Anguish wrote: On Feb 16, 2010, at 5:45 PM, Simon Wolf wrote: I'm wondering when writing a layer hosting view, when the most appropriate time is to set the layer and call -setWantsLayer:YES? Calling it in -initWithFrame: is too early and the view fails to 'draw'. In addition to David's reply, a small tip is that you can also get things working if you call setWantsLayer: and then follow it by assigning a layer: [self setWantsLayer:YES]; [self setLayer:[CALayer layer]]; Otherwise the layer is added at some undetermined future point which may not (in my experience ever) be in the current run loop. This is incorrect. If you want a layer-hosting view (rather than a layer-backed view) you must do this in the reverse order. setLayer: and then setWantsLayer: Ah, that may explain some of the problems I was having! Thanks Scott. Simon Wolf Website: http://www.ottersoftware.com Twitter: http://www.twitter.com/sgaw iChat: simon.w...@mac.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: some advice on asynchronous control please
On Feb 19, 2010, at 4:06 PM, Damien Cooke wrote: I have a situation where I am using a 3rd party library to manage content on their service. When I delete an entry the method requires a call back all good. Now I need to wait for that call back to be called to know if it was successful or not. In the call back I can set a boolean to indicate success or not but waiting for that to be set is my issue. What is the right way to wait for it? I think while(!done) { [NSThread sleepForTimeInterval:1]; } Just blocks the main thread which is not what I want at all as this also blocks the run loop also. Can anyone give me some guidance on the best practice for this situation? The best thing is to restructure your code. Split it into the part that can happen before the callback and the part that has to happen afterward. Once you've done the part that can happen before, simply return out of your code back to the main event loop. When the callback happens, simply resume with the part that happens afterward. If you can't do the 'afterward' part while you're being called back from the library, you can use -performSelector:withObject:afterDelay: with a 0 delay. That will allow control to return to the library and arrange for your 'afterward' part to be done when control returns to the main event loop. If the library issues its callback on a background thread, you can use -performSelectorOnMainThread:withObject:waitUntilDone: instead. That will invoke your 'afterward' method on the main thread, when it's idle in the event loop. You would pass NO for the 'wait' parameter to allow control to return to the library immediately in the background thread. Cheers, 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: NSTableView with PopUpButtonCell column with different content per row
On 2010 Feb 19, at 13:30, Sean McBride wrote: In my case currently, I need several separators and also an 'other...' item that brings up an open panel. I don't know about the separators but I have done the 'Other...' item successfully. Referring to my previous message, define a new class called FooChoice which is a thin wrapper around a Foo. A regular FooChoice will have a Foo ivar, but your Other... FooChoice will instead have a selector ivar. Now, add to your model fooChoice and setFooChoice: methods which transform between Foo and FooChoice. When setFooChoice: gets a fooChoice with a selector instead of a foo, it plays an NSOpenPanel. (I suppose an MVC purist might do this in a controller class somewhere, but oh well it works for me.) The FooChoice is kind of like a proxy, right? Don't forget +keyPathsForValueAffectingXxx. I'm pasting in below my ClientChoice class code. It looks like it has some comments in it that you might find interesting. #import Cocoa/Cocoa.h @class Client ; /*! @briefA thin wrapper around a client, or a placeholder which allows users to choose Other Mac Account or Choose File instead of an existing client. @details A client choice which wraps a client will have a non-nil client ivar and a nil selector.nbsp; A client choice which wraps a placeholder will have a nil client and a non-nil selector. */ @interface ClientChoice : NSObject { Client* m_client ; SEL m_selector ; id m_object ; } /*! @briefThe receiver's title, suitable for display as the title of a (popup) menu item. */ @property (readonly) NSString* displayName ; @property (retain) Client* client ; @property (assign) SEL selector ; @property (retain) id object ; /*! @briefReturns a ClientChoice defined by a client. @details Returns a ClientChoice even if client is nil. This is so that the localized No Selection placeholder can be returned for displayName and appear in the popup in this case. @paramclient The client that is being wrapped */ + (ClientChoice*)clientChoiceWithClient:(Client*)client ; + (ClientChoice*)clientChoiceInvolvingOtherMacAccount ; + (ClientChoice*)clientChoiceInvolvingLooseFile ; + (ClientChoice*)clientChoiceNewOtherAccountForWebAppExformat:(NSString*)exformat ; @end #import ClientChoice.h #import Client.h #import NSString+LocalizeSSY.h ; #import BkmxBasis+Strings.h #import Extore.h @implementation ClientChoice @synthesize client = m_client ; @synthesize selector = m_selector ; @synthesize object = m_object ; - (NSString*)displayName { NSString* displayName = nil ; Client* client = self.client ; if (client) { displayName = [client displayName] ; } else { SEL selector = [self selector] ; if (selector) { NSString* targetString = NSStringFromSelector(selector) ; NSString* aString ; aString = @chooseClientOnOtherMacAccountWithObject: ; if ([targetString isEqualToString:aString]) { displayName = [NSString stringWithFormat:@%C %@, 0x27a4, [NSString localize:@accountMacOther]] ; } else if ([targetString isEqualToString:@chooseClientFromFile]) { displayName = [NSString stringWithFormat:@%C %@ %@, 0x27a4, [NSString localizeFormat: @choose%0, [NSString localize:@file]], [[BkmxBasis sharedBasis] labelAdvanced]] ; } else if ([targetString isEqualToString:@setClientWithNilProfileForWebAppExformat:]) { NSString* newSlashOther = [NSString stringWithFormat: @%@/%@, [NSString localize:@new], [NSString localize:@other]] ; displayName = [NSString stringWithFormat: @%@ - %@, [[Extore extoreClassForExformat:[self object]] ownerAppDisplayName], newSlashOther] ; } else { NSLog(@Internal error 510-5918. sel=%@, targetString) ; } } else { displayName = [NSString localizeFormat:@no%0, [NSString localize:@selection]] ; } } return displayName ; } + (ClientChoice*)clientChoice { ClientChoice* clientChoice = [[ClientChoice alloc] init] ; return [clientChoice autorelease] ; } + (ClientChoice*)clientChoiceWithClient:(Client*)client { ClientChoice* clientChoice = [ClientChoice clientChoice] ; [clientChoice setClient:client] ; return clientChoice ; } + (ClientChoice*)clientChoiceInvolvingOtherMacAccount { ClientChoice* clientChoice = [ClientChoice
Re: How to detect if mouse on border of view
On Feb 19, 2010, at 13:36, Mazen M. Abdel-Rahman wrote: Thanks everyone for your help on this. I wanted to know if the mouse was on the border area prior to the mouse down event to determine if the mouse icon should change as the mouse hovers over the border. Is there a way to do this without a mouseMoved event? I think the easiest way to do this is to use two NSTrackingAreas, one inset inside the other. When the mouse is inside the larger one but outside the smaller one, the mouse is in the border. You could use mouseEntered:/mouseExited: to determine the state, and cursorUpdate: to set the mouse cursor appropriately. However, I think this border behavior has another, trickier UI aspect. The border that the user can drag really needs to extend beyond the apparent rectangle. That is, if I'm try to grab what appears to be the border, it should be OK if I'm a couple of pixels outside it or a couple of pixels inside it. This means a bit more work for you, because you'll have to do something like one of these: 1. Make your actual view frame slightly larger than you need for drawing, so that the actual grab-able border is literally within the view. 2. Use the natural view frame, but embed your view inside a slightly larger view that represents the outside edge of the border. 3. Detect the mouse position (relative to the border) at a higher level in the view hierarchy, so that you're not restricted by the actual frame of the view being resized. 4. Avoid using a view for each of the iCal-like-event elements, but simply draw them as graphic elements within a larger view that represents the calendar. (When there can possibly be many graphic elements, making each one a separate view is not necessarily the best choice.) ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Animating an Attached Window (was: Drawing Attention to a Control...)
[[self window] setAnimations:[NSDictionary dictionaryWithObject:[self shakeAnimation:[[self window] frame]] forKey:@frameOrigin]]; [[[self window] animator] setFrameOrigin:[[self window] frame].origin]; /* shake animation http://www.cimgf.com/2008/02/27/core-animation-tutorial-window-shake-effect/ */ - (CAKeyframeAnimation *)shakeAnimation:(NSRect)frame { CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animation]; CGMutablePathRef shakePath = CGPathCreateMutable(); CGPathMoveToPoint(shakePath, NULL, NSMinX(frame), NSMinY(frame)); int idx; for (idx = 0; idx numberOfShakes; ++idx) { CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) - frame.size.width * vigourOfShake, NSMinY(frame)); CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) + frame.size.width * vigourOfShake, NSMinY(frame)); } CGPathCloseSubpath(shakePath); shakeAnimation.path = shakePath; shakeAnimation.duration = durationOfShake; return shakeAnimation; } - (CAKeyframeAnimation *)shakeAnimation:(NSRect)frame { CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animation]; CGMutablePathRef shakePath = CGPathCreateMutable(); CGPathMoveToPoint(shakePath, NULL, NSMinX(frame), NSMinY(frame)); int idx; for (idx = 0; idx numberOfShakes; ++idx) { CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) - frame.size.width * vigourOfShake, NSMinY(frame)); CGPathAddLineToPoint(shakePath, NULL, NSMinX(frame) + frame.size.width * vigourOfShake, NSMinY(frame)); } CGPathCloseSubpath(shakePath); shakeAnimation.path = shakePath; shakeAnimation.duration = durationOfShake; return shakeAnimation; } Note that this code does not have any effect when compiled as 64-bit. I don't remember all the details at the moment, but I believe the issue is that the 'frameOrigin' property doesn't work under 64-bit. In my own code I was forced to use the 'frame' property instead, which changes the code a bit, but works for both 32- and 64-bit. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Core Animation: What is a trigger key?
In documentation of the protocol NSAnimatablePropertyContainer, -setAnimations: Sets the option dictionary that maps event trigger keys to animation objects. What is a trigger key? I can't find any mention of trigger key in Core Animation Programming Guide. Any relation to an animatable property? Thank you, Jerry Krinock ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Monitoring other application preferences changes
Greetings. I'm trying to figure out how to monitor the preferences changes in another application's preferences I would like my application to react to changes made in another application settings by the user. besides reloading the plist on a schedule is there a better way? ( I don't like this ) if there is a way to KeyValue Observe it that would be dandy. Can anyone point me in the right direction ? Regards. Sandro Noel. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Monitoring other application preferences changes
i would think you could use FSEvents to be informed of any changes to a .plist file. On Feb 19, 2010, at 8:24 PM, Sandro Noël wrote: Greetings. I'm trying to figure out how to monitor the preferences changes in another application's preferences I would like my application to react to changes made in another application settings by the user. besides reloading the plist on a schedule is there a better way? ( I don't like this ) if there is a way to KeyValue Observe it that would be dandy. Can anyone point me in the right direction ? Regards. Sandro Noel. ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/intrntmn%40aol.com This email sent to intrn...@aol.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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Monitoring other application preferences changes
On Fri, Feb 19, 2010 at 5:57 PM, Jack Carbaugh intrn...@aol.com wrote: i would think you could use FSEvents to be informed of any changes to a .plist file. You have no guarantee that this is how an application is storing its preferences. And for apps that do use this method, they might synchronize their preferences at random times--perhaps not even until they quit. --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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
NSPathStore2 HELP!!!!!!
Subject: Re: NSPathStore2 HELP!! Ok, here is how I solved this. Before I called [NSKeyedUnarchive unarchive...], I called the class method: [NSKeyedUnarchiver setClass:[NSString class] forClassName:@NSPathStore2]; This fixed the errors and allowed me to reclaim the data. NSPathStore2 can not be initialized, so I just told the Unarchiver to treat it as a NSString instead. On Feb 19, 2010, at 4:46 PM, Patrick Cusack wrote: I have serialized by an NSDictionary object using NSKeyedArchiver in my document's save method. When I unarchive the data, I get a error *** initialization method -initWithCharactersNoCopy:length:freeWhenDone: cannot be sent to an abstract object of class NSPathStore2: Create a concrete instance! This is killing me as I can't restore my data. Any thoughts?? Please help Patrick ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Removing item from CollectionView by drag it out.
Greetings I've been looking at Collection View Drag and drop, I've implemented the NSCollectionViewDelegate and now I can Drop items in and everything works fine. I've been looking at removing items from the collection view by dragging them out of the frame. I'm confused by the proper procedures. writeItemsAtIndexes happens just before the item is dragged and just after canDragItemsAtIndexes returns YES. How would i go about it ? 1: when the item is dragged out of the frame, I want to remove it from the collection view as to show that I am holding the item out of the collection ( i got it in my hands and it's in limbo ) 2: I could at any point drop the item back on the collection view as to cancel the deleting of the item 3: I could drag the item to another collection view in the same application as to move the item around. 3: if the item is released outside of any collection view it is lost (deleted). if anyone can point me to a good example, that would be great. Cheers! Sandro___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
initWithCoder / unarchiveObjectWithData Memory Management Question
I have a memory management question involving the interaction of: - (id) initWithCoder: (NSCoder*) coder from any class that implements NSCoding and + (id) unarchiveObjectWithData: (NSData*) data from the NSKeyedUnarchiver (or any unarchiver) class. After the following lines of code run ... NSData* data = [NSData dataWithContentsOfFile: myObjectPath]; myObject = [NSKeyedUnarchiver unarchiveObjectWithData: data]; (error handling removed), has myObject been retained, or must I now retain it. The unarchiveObjectWithData class method causes myObject's class's initWithCoder object method to run. I assume that initWithCoder obeys memory management rules and returns a newly alloc'ed and retained object. Does the unarchiveObjectWithData method return that retained object unaltered, or does it autorelease it first, so that the unarchiveObjectWithData method obeys the usual convention of class factory methods to return autoreleased objects? I apologize for asking this seemingly basic question, but I can't find the answer in the Apple docs or via googling, and there seems to me to be a clash of well-established conventions involved. The question came up because I found a case in my code where I convinced myself I was over-releasing an object created in this fashion, but the application never fails because of it. Thanks, Tom Wetmore, Chief Bottle Washer, DeadEnds Software ___ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com