Aha, I see what you're saying. Well, I just played around with this, and subclassing an NSButton as follows will create a button that looks enabled but won't respond to mouse clicks and also won't allow users to tab to the button (ie, disallows the focus):

@interface FakeButton : NSButton { }
@end

@implementation FakeButton

- (BOOL) acceptsFirstReponder { return NO; }

- (BOOL) becomeFirstResponder { return NO; }

- (void) mouseDown:(NSEvent *)event { return; }

- (void) mouseUp:(NSEvent *)event { return ; }

@end

Just tried it and it works as I've described above.

Dave

On Jan 12, 2009, at 12:08 PM, Andy Lee wrote:

But it will still visually respond to mouse clicks, which is not desired, in my interpretation of the problem statement. [[theButton cell] setHighlightsBy:NSNoCellMask] presumably takes care of that -- but then the user might still be able to select the button by tabbing to it.

If a single NSButton is used, I think the easiest thing is to disable it and then override its drawing behavior, as I. Savant suggested. But it depends on the context of what the application is trying to do. If the application displays a screenful of different fake UI components (for example, as a sort of "mockup," as I.S. posited), it would be impractical to have a subclass for every control/cell. In that case, some sort of offscreen drawing makes sense -- draw the whole window/view offscreen, not even bothering to disable the controls, and blit it to the real window.

--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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to