Re: Enabling add button
Re: Enabling add button
- Subject: Re: Enabling add button
- From: Mark <email@hidden>
- Date: Fri, 19 Dec 2008 11:29:25 +0000
I did something like this once. I'm not sure if this is a good way to
tackle the problem or not but here's what you need:
- A BOOL ivar exposed as a property on one of your controllers:
BOOL isTableViewSelected;
@property(assign) BOOL isTableViewSelected;
@synthesize isTableViewSelected;
- Next, set up an observer of NSWindowDidUpdateNotification in -
awakeFromNib or somewhere else so we can watch for any changes in the
window (like first responder changing):
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(checkFirstResponderStatusNotification:)
name:NSWindowDidUpdateNotification
object:[aView window]]; // <-- Get to the main window somehow
- In the selector for the notification check the class of the first
responder and then set the isTableViewSelected ivar accordingly. By
using the synthesized setter it broadcasts change notifications so you
can bind the 'Enabled' binding of the button to
yourController.isTableViewSelected and it should then update its
status correctly as you move around your UI.
- (void)checkFirstResponderStatusNotification:(NSNotification *)note {
NSWindow *mainWindow = [self.aView window]; // <-- Get to the main
window somehow
self.isTableViewSelected = ([[mainWindow firstResponder]
isKindOfClass:[NSTableView class]]);
}
I think this should work, you'll probably have to fiddle about with
some things (I originally used this to check the class of one of my
own classes, not a table view). I think there was some weird problems
with flickering (rapid on/off changes?) when a sheet was present on
the window which I never got round to solving, ymmv.
(Also [[NSNotificationCenter defaultCenter] removeObserver:self]; in -
dealloc or elsewhere)
On 18 Dec 2008, at 23:28, Andre Masse wrote:
On Dec 18, 2008, at 15:43, I. Savant wrote:
The issue Andre mentioned is that the app is mostly keyboard-driven
(and the key combo fires the button, which he fears can be triggered
inadvertently). This means it doesn't matter where the button is -
the
key combo can still trigger the action without calling "enough"
attention to the resulting insert.
Exactly. You're way better than me explaining my own problems :-) I
used to talk/write English much more 5-6 years ago (even co-
translated a book from French to English). Now, I only use English
in this list and it shows :-)
Thanks,
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
_______________________________________________
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