Re: Strategies for reusing NSPopover
Re: Strategies for reusing NSPopover
- Subject: Re: Strategies for reusing NSPopover
- From: Martin Hewitson <email@hidden>
- Date: Sat, 13 Aug 2011 17:38:04 +0200
On 13, Aug, 2011, at 05:30 PM, Andre Masse wrote:
>
> On 13/08/2011, at 08:54 , Martin Hewitson wrote:
>
>> Suppose I have two date picker controls. Beside each I place a button. The button shows a popover hosting a view controller whose view contains a graphical date picker. When I get the delegate message back that the popover closed, how can I know which button caused the popover to be shown? I was looking for some kind of user-info which would appear in the notification, but I can't find anything so far. I could have two popovers, then select in the delegate that way, but that seems very inelegant.
>
> There are many ways to do this. Two from the top of my head:
>
> You could use a button typed as "Push On Push Off" and check its state. Or use an ivar like "lastButtonPushed".
Yes, the ivar approach should work.
In the end I tried the following. Made an NSViewController subclass with a property 'sender'. Then I can set this to the button that was clicked and recover it in the popover delegate to decide which button was clicked and what to do with the data stored in the view controller. As I'm writing this I realise it would be much nicer to pass a reference to the model object to the view-controller before launching the popup, then have the view controller update the model object. I'll play with this some more.
Martin
>
>> On a side note, if I search for NSPopover in the Xcode documentation, it only finds NSPopoverDelegate, but not the class documentation. Anybody else have similar problems? I'm using Xcode 4.1 and the documentation is up to date.
>
> Yeah, doc is incomplete at this point. The header is nicely documented though.
>
> I'm playing with popover too and noticed a problem when using formatters. If there's a validation error, my application crashes when the framework try to present a sheet displaying the error.
>
> -[NSPopoverFrame titlebarRect]: unrecognized selector sent to instance 0x102075780
>
> Of course, popovers don't have titlebars...
>
> Andre Masse
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden