It's exactly what I need, Dave. Thank you!
A small question: there is "Enable access for assistive devices" in
Universal Access, what do you think, can any of these devices treat my
fake button as a real button (even if the button don't accepts "first
responder")? Or removing first responder from a button guarantees that
it never be accessible?

On Mon, Jan 12, 2009 at 10:57 PM, Dave DeLong <davedel...@me.com> wrote:
> I'll also point out that this will work for any NSButton flavor (checkboxes,
> help, recessed, etc).  I just did some further testing to make sure that
> these buttons refuse the focus, and they definitely don't accept being first
> responder.  I created an interface with a bunch of normal buttons, wired up
> the nextKeyView to be sequential, and then wired the last of the normal
> buttons to the first of the FakeButtons.  (I also wired the first normal
> button to be initialFirstResponder).  I turned on full access in SysPrefs,
> then ran the app.
>
> Hitting the tab button will ONLY tab through the normal buttons.  Even
> though one of the FakeButtons is wired to be the nextKeyView, since it
> refuses first responder, it just jumps to the next thing that does accept
> first responder (this being one of the normal buttons).
>
> If that doesn't do what he's asking for, then I have no clue what will.
>
> Dave
>
> On Jan 12, 2009, at 12:18 PM, Dave DeLong wrote:
>
>> 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
>
> _______________________________________________
>
> 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/lprpro%40gmail.com
>
> This email sent to lpr...@gmail.com
>
_______________________________________________

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