Re: Custom binding problem...can't figure out how to trigger a notification on set
Re: Custom binding problem...can't figure out how to trigger a notification on set
- Subject: Re: Custom binding problem...can't figure out how to trigger a notification on set
- From: Mike Abdullah <email@hidden>
- Date: Mon, 2 Oct 2006 08:51:16 +0100
Well to be honest, I'm not entirely sure I understand what you're
after here!
I understand that you're creating a custom NSView subclass. As part
of this subclass's functionality, it should have a changeable
background colour. When using this, the user will add an
NSObjectController to their nib and then bind the backgroundColor of
the view to this.
So, is what you're now asking about, the palette that appears in
Interface Builder to handle the customisation of the view in IB?
Mike.
On 29 Sep 2006, at 23:07, E. Wing wrote:
Thank you for the reply. That makes a lot of sense. But here's a
follow up question. Can you tell me how I might solve this problem if
I was trying to make a change within MyCustomView class directly? My
motivation is that I'm writing a stand-alone library palette for the
view that can be setup through Interface Builder. So it's up to a user
of my palette to provide the object controller and other connections.
So imagine if my view needed to change its color internally, like a
reset, or maybe a time triggered color change, or maybe something that
is triggered on the View's mouseDown event. How do I notifiy the
object controller about this change?
Thanks,
Eric
On 9/29/06, Mike Abdullah <email@hidden> wrote:
Hi Eric, I can tell you exactly what your problem is :)
You have an NSObjectController to which you are binding your custom
view and the color well. That is fine and works as it should.
When you set the color using the well, this sets the color of the
NSObjectController and the view then picks up that this has happened.
However, when you set the color using one of the buttons, you are not
setting the color of the NSObjectController like you should. Instead
you are setting the color of the view directly. By doing this, the
color well never "sees" this change.
So, simply change your calls to something like:
[colorController setValue: [NSColor redColor] forKey:
@"backgroundColor"];
Mike.
On 29 Sep 2006, at 08:12, E. Wing wrote:
> Hello, I have a simple bindings problem I'm hoping somebody can
help
> me with. I have condensed down my problem into a simple example
> program which I have posted here:
> http://www.geocities.com/ewing2121/NotificationProblem.tgz
>
> Basically, I have a custom view object with a property I want to
bind.
> In this case, it is color. I wish to bind my color property to the
> NSColorWell widget.
>
> My problem is that the bindings seem to only work in one
direction. I
> can change the color wheel from the NSColorWell and my view object
> changes appropriately. But if I set my view object's color
directly,
> the NSColorWell does not seem to get the notification that I
changed
> the view color so it does update itself.
>
> I don't know what I'm supposed to do to 'trigger' this
notification.
> Can some body tell me where I'm going wrong?
>
> The example program has a custom view that paints the entire
view the
> specified color. If you click on the NSColorWell, you should be
able
> to change the view colors. If you click on the buttons labeled with
> different color names, they change the view color, but the
NSColorWell
> will not change to keep in sync.
>
> Thanks,
> Eric
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> 40gmail.com
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden