Re: Enable Buttons
Re: Enable Buttons
- Subject: Re: Enable Buttons
- From: "M. Uli Kusterer" <email@hidden>
- Date: Sat, 2 Jul 2005 01:22:26 +0200
At 20:33 Uhr +0200 01.07.2005, Gerriet M. Denkmann wrote:
I'd add a doFindNext: method to the First Responder in IB, and
connect the button to that. Then, add that method to your document
class. Cocoa will do the Right Thing(tm), sending the action to the
current document and disabling the button if none of the objects in
the responder chain respond to the specified action.
I tried this. Cocoa does indeed the Right Thing in sending the
action to the current document.
But it does not disable the butten when there is not document at all.
What am I doing wrong?
As far as I know, the approach described above only works with
toolbar items and menu items. To have it work for any others, I guess
you'd need to write some code of your own.
As a starting point, you could use something like:
http://www.zathras.de/angelweb/blog-validate-user-interface.htm
but extend it with a check for a responder that accepts this message.
But it would probably be rather inefficient.
The "correct" way and a more efficient one would probably be to add
a KVC-compliant property to your app delegate class that returns
[[NSDocumentController sharedDocumentController]
currentDocument] != nil
and bind that to the button's "enabled" property. But I haven't tried
that before, so I can't tell you where the pitfalls in any of this
might be. I don't even know whether IB lets you hook up bindings to
methods in user-defined objects.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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