How to remove NSUserNotification from NotificationCenter

2013-07-03 Thread anni saini


I am using NSUserNotificationCenter to display scheduled Notifications. I have 
notifications of my app in the right side notification panel so whenever I 
click on the notification it'll launch the app but it won't remove notification 
from the panel.

1. When app is not running and I clicked on the notification, 
applicationDidFinishLaunching is called and it won't remove notification 
because didActivateNotification delegate is not called.
2. When application is already running and I clicked on the notification, 
appShouldHandleReopen is called. And won't call the delegate.

-(void)userNotificationCenter:(id)center 
didActivateNotification:(id)notification

I checked behavior in all the standard app they will remove notification when 
user click on the notifications.

I have implemented it as follows:

    /* will create notification and set the delegate*/
    @interface NotificationViewController : NSViewController
    {
    id delegate;
    }
    -(void)showNotification;
    @end
    
    @implementation NotificationViewController
    - (void)createNotification:(NSString*)str
    {
    
    Class UserNotificationClass=NSClassFromString(@NSUserNotification);
    id notification = [[UserNotificationClass alloc] init];
    //Set the title of the notification
    [notification setTitle:@My Notification];
    [notification setSubtitle:@Test];
    [notification setHasActionButton:YES];
    [notification setActionButtonTitle:@OK];
    [notification setOtherButtonTitle:@CANCEL];
    
    //Set the text of the notification
    [notification setInformativeText:str];
    [notification setDeliveryDate:[NSDate dateWithTimeInterval:0.1 
sinceDate:[NSDate date]]];
    [notification setSoundName:@NSUserNotificationDefaultSoundName];
    [notification setUserInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:str,@string,nil]];
    
    Class 
UserNotificationCenterClass=NSClassFromString(@NSUserNotificationCenter);
    id center = [UserNotificationCenterClass defaultUserNotificationCenter];
    [center setDelegate:self.delegate];
    
    //Scheldule our NSUserNotification
    [center scheduleNotification:notification];
    [notification release];
    }
    @end

    /* Class which implements NSUserNotificationDelegate
    
    @interface NotificationHandler : NSObject NSUserNotificationCenterDelegate
    {
    
    }
    - (void)createNotification:(NSString*)str;
    @end
    
    
    @implementation NotificationHandler
    - (void)createNotification:(NSString*)str
    {
    NotificationHandler *notificationHandler = [[NotificationHandler alloc] 
initWithNibName:@NotificationHandler bundle:[NSBundle mainBundle]];
    notificationHandler.delegate = self;
    [notificationHandler showNotification];
    }
    
    - (void)userNotificationCenter:(id)center 
didActivateNotification:(id)notification
    {
    [center removeDeliveredNotification:notification];
    }
    
    - (BOOL)userNotificationCenter:(id)center 
shouldPresentNotification:(id)notification
    {
      return YES;
    }
    @end

However this is not working in my case. Please let me know some pointer on it...

**Other thing I observed:**

 - When I implement NSUserNotificationDelegate into AppDelegate it'll work for 
2nd case i.e. (When application is already running and I clicked on the 
notification) - in this case notification is removed.
 - And for deleting notification for 1st case i.e. (When app is not running and 
I clicked on the notification, appDidFinishLaunching is called) I wrote 
following code in appDidFinishLaunching.

    NSUserNotification *userNoti = [[notification userInfo] 
valueForKey:@NSApplicationLaunchUserNotificationKey];
    [[NSUserNotificationCenter defaultUserNotificationCenter] 
removeDeliveredNotification:userNoti];

- Can anybody let me know whats the reason, why this works in the AppDelegate 
but not in my above implementation or Am I doing something wrong in first one?
- Is my AppDelegate implementation fine to handle my both scenarios? 

Thanks in Advance.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: iOS OpenGL ES woes

2013-07-03 Thread Vincent Habchi
David,

BTW, is it possible to add subviews to a CAEAGLLayer backed view? I have been 
fighting all day to show a progress indicator atop this backed view, in vain.

Thanks!
Vincent


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Carbon removal

2013-07-03 Thread Chris Paveglio
I've got a project that I am working with, that I did not create. I am trying 
to understand it and I would like to remove the Carbon framework dependencies 
in it. I don't know anything about Carbon. Is there a good resource to read up 
on it? Are there replacement methods in other frameworks to replace some of the 
Carbon apis? I'm not really sure where to start.

For example, here's a function I will need to replace, where could I find any 
of the same calls or another function to replace OSStatus?

pascal OSStatus AppEventHandler( EventHandlerCallRef inCallRef, EventRef 
inEvent, void* controller ) 
{
  OSStatusstatus = eventNotHandledErr;
  
  if(GetEventClass(inEvent) == kEventClassApplication) 
  {
    UInt32 mode = 0;
    (void) GetEventParameter(inEvent,
                             kEventParamSystemUIMode,
                             typeUInt32,
                             NULL,
                             sizeof(UInt32),
                             NULL,
                             mode);
    [controller modeDidChange:mode];
    status = noErr;
  }
  return status;
}
--
and later
--
InstallApplicationEventHandler( NewEventHandlerUPP( AppEventHandler),
                                 GetEventTypeCount( sAppEvents ),
                                 sAppEvents, self, NULL );
---
Thanks for any help.
Chris
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: iOS OpenGL ES woes

2013-07-03 Thread David Duncan
On Jul 3, 2013, at 10:08 AM, Vincent Habchi vi...@macports.org wrote:

 David,
 
 BTW, is it possible to add subviews to a CAEAGLLayer backed view? I have been 
 fighting all day to show a progress indicator atop this backed view, in vain.


Yes, as long as you wrap the CAEAGLLayer with a UIView (override +layerClass), 
then you can add subviews to that view to your hearts content.
--
David Duncan


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: iOS OpenGL ES woes

2013-07-03 Thread vincent habchi
David,
 Yes, […]

Thanks for your quick answer and your kindness, as usual! Then something is 
wrong with my setup, I’ll investigate further.

Have a great day!
Vincent


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Carbon removal

2013-07-03 Thread Jens Alfke

On Jul 3, 2013, at 10:23 AM, Chris Paveglio chris_paveg...@yahoo.com wrote:

 For example, here's a function I will need to replace, where could I find any 
 of the same calls or another function to replace OSStatus?

This is an event handler — I’m not sure what it’s doing, but it’s certainly 
going to have to be done completely differently in a Cocoa app, because AppKit 
is doing this kind of low-level event handling internally.

It looks like this is getting a parameter named “kEventParamSystemUIMode” from 
the event and passing its value to [controller modeDidChange:]. You could start 
by looking up that this parameter means, and then see what the Cocoa equivalent 
is.

—Jens

smime.p7s
Description: S/MIME cryptographic signature
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Carbon removal

2013-07-03 Thread Jerry Krinock

On 2013 Jul 03, at 10:23, Chris Paveglio chris_paveg...@yahoo.com wrote:

 I am trying to understand it and I would like to remove the Carbon framework 
 dependencies in it.

As I understand it, the box surrounding Carbon is fuzzy.  There are even some 
API documents with Carbon in their names whose functions are going to be 
around forever.

To answer your question, I think the procedure is…

* In your main target and its target dependencies,
  * Set the SDK to Latest Mac OS X.
  * Set the architecture to x86_64.
* Clean your project, so that everything will be recompiled.
* Analyze your project (⇧⌘B).

After it's done, look at the newly-produced Build log in the Logs navigator.  
Any deprecated or no-longer-existing functions and types should be listed as 
warnings and errors.  Fix and repeat.

Even the two functions you mentioned may in fact turn out to be OK.  I don't 
think that the OSStatus type is going away.
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: Why are these layout constraints being ignored?

2013-07-03 Thread Rob Nikander
Thanks, it's good to know I'm not the only one. I've abandoned constraints
for now and am using the old way.

Rob


On Tue, Jul 2, 2013 at 12:43 PM, Kyle Sluder k...@ksluder.com wrote:

 On Jun 25, 2013, at 6:10 AM, Rob Nikander rob.nikan...@gmail.com wrote:

 
  I create 4 constraints with the desire to pin the NSOutlineView to the
  edges of it's superview (the NSWindow's contentView). It works, until I
  expand/collapse items in the outline view. Then the constraints are
 ignored
  and the outline shrinks.  Why are they ignored? What is it in the outline
  view that is taking priority? It's intrinsicContentSize is (-1,-1) which
 I
  thought meant it could be stretched out to satisfy other constraints.

 Long story short, NSOutlineView (and NSTableView) will do one of two
 behaviors when tiling:

 1. Inside an NSClipView (which is the case when it is the document view of
 an NSScrollView), it will fill its clip view or its content, whichever is
 bigger.

 2. Outside of an NSClipView, it will resize to hug its content as small as
 possible.

 Obviously, neither of these is compatible with auto layout. There are no
 override hooks to customize this behavior. The only thing I have found that
 works reliably is to put the table view inside an NSClipView, and resize
 that appropriately.

 Please file radars on the inflexibility of NSTableView. I know I have.

 --Kyle Sluder
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

[MEET] Toronto Cocoaheads / tacow - July 9

2013-07-03 Thread Karl Moskowski
tacow's next meeting is scheduled for 6:30 PM on Tuesday, July 9, 2013 in 
meeting room 310 of Metro Hall.

Ash Furrow will be discussing UICollectionView. For more details and to RSVP, 
head over to http://www.meetup.com/tacow-org/events/124074922/.
 
Thanks, and see you there!

—Karl.

smime.p7s
Description: S/MIME cryptographic signature
___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: NSSplitView similar to Xcode's editor/debug area split view

2013-07-03 Thread Chuck Soper
Hi Andy,

Thanks for this code snippet. It was exactly what I was asking for, but it
didn't fit for my specific situation. I now have a split view with three
subviews with different holding priorities. The only way I could get this
to work was to use constraints, and animate them. It's mostly
straightforward, but care needs to be taken to avoid breaking the
constraints.

Basically, when the lower pane is showing, I only have these constraints:
  @V:[lowerView(=80,=200)]
and when the lower pane is hiding, I only have this constraint:
  @V:[lowerView(==0)]

To animate the height, one can use this:

[NSAnimationContext runAnimationGroup:^(NSAnimationContext *context) {
[context setDuration:0.15];
[lowerPaneFixedHeightConstraint.animator setConstant:newHeight];
} completionHandler:nil];


I'm interested to hear if anyone else is using constraints to animate a
subview of an NSSplitView.

Chuck



On 6/28/13 4:58 AM, Andy Lee ag...@mac.com wrote:

Hi Chuck,

On Jun 26, 2013, at 8:30 PM, Chuck Soper chu...@veladg.com wrote:
 2. How should I animate the showing or hiding of the 'debug area' view?

I do by sending setFrame: to the two subviews' animator proxies instead
of to the view itself.

// Assumes the split view has two subviews, one above the other.
- (void)_setTopSubviewHeight:(CGFloat)newHeight
 forTwoPaneSplitView:(NSSplitView *)splitView
 animate:(BOOL)shouldAnimate
{
NSView *viewOne = [[splitView subviews] objectAtIndex:0];
NSRect frameOne = [viewOne frame];
NSView *viewTwo = [[splitView subviews] objectAtIndex:1];
NSRect frameTwo = [viewTwo frame];

frameOne.size.height = newHeight;
frameTwo.size.height = ([splitView bounds].size.height
- [splitView dividerThickness]
- newHeight);
if (shouldAnimate)
{
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.1];
{{
[[viewOne animator] setFrame:frameOne];
[[viewTwo animator] setFrame:frameTwo];
}}
[NSAnimationContext endGrouping];
}
else
{
[viewOne setFrame:frameOne];
[viewTwo setFrame:frameTwo];
}
}

There may be a better way, but this seems to work.

--Andy


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: voiceover question

2013-07-03 Thread Rick C.
I have some more info about my post the other day (below) it actually goes back 
to this discussion here some months back:

http://www.cocoabuilder.com/archive/cocoa/326386-2-icons-showing-in-dock.html

In trying to solve this double-icon issue (which I'm not sure that I did) I 
introduced this VoiceOver issue.  I found that if I put setActivationPolicy: 
back into +initialize I do not have the VoiceOver issue.  Where are we actually 
supposed to use setActivationPolicy: anyways?  Also, with the VoiceOver issue I 
have tried to use -NSAccessibilityDebugLogLevel 1 to no effect on figuring out 
what the issue is.  Any other thoughts?

Thanks,

rc



On Jun 27, 2013, at 7:39 PM, Rick C. rickcort...@gmail.com wrote:

 Hi,
 
 Apparently in my app when it is launched with VoiceOver running and the user 
 tries to use Control-Option-M to access the menu it does not work.  By 
 quitting VoiceOver and relaunching it works fine.  I have also confirmed 
 this.  Any idea on why this would happen?  I certainly never did anything 
 intentionally to cause this behavior.  Thanks!
 
 rc


___

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

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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