Re: All buttons lost focus ring on Yosemite
Re: All buttons lost focus ring on Yosemite
- Subject: Re: All buttons lost focus ring on Yosemite
- From: Dragan Milić <email@hidden>
- Date: Mon, 09 Mar 2015 17:29:47 +0100
On pon 09.03.2015., at 16.33, Motti Shneor wrote:
>> Date: 9 במרץ 2015 בשעה 11:58:11 GMT+2
>> From: Dragan Milić <email@hidden>
>> Subject: Re: All buttons lost focus ring on Yosemite
>> To: Cocoa-dev <email@hidden>
>>
>> On pet 06.03.2015., at 18.37, Kyle Sluder wrote:
>>
>>> On Fri, Mar 6, 2015, at 10:49 AM, Dragan Milić wrote:
>>>
>>>> Thanks for the suggestion. A bad category was something I also thought could be the reason for this behaviour, but it looks like it isn’t. There are no NSButton, NSButtonCell, nor NSControl categories. There is a single NSView category, but it doesn’t do anything related to drawing, it just defines and implements some convenient methods for finding subviews and superviews of a certain class.
>>>
>>> Please post the code for this category. Maybe it's colliding with an internal implementation detail of the focus ring mechanism.
>>
>> Sure, no problem. Since it’s a bit long, I attached it as a separate ObjC source file. A few notes:
>>
>> * It’s rather old code (not made by me) that I haven’t looked into for years until this problem appeared.
>> * I rearranged it a bit for easier reading, so there may be some copy/paste/typo errors, but you should get the overall idea what it does.
>> * All drawing related code is contained within unique methods, no overriding.
>> * I was “lying”, there is a small NSButton category (defined within the same file), but it just checks if a button is of a checkbox type.
>>
>> Thanks for looking into this, as I really hit a dead end with it.
>>
>> <NSView-NTExtensions.m>
>
> Your category NSView+NTExtensions defines “drawFocusRing” and overrides LOTS of native NSView methods…
Which native NSView methods are overridden? Perhaps I’m missing something, but I’ve just class-dumped AppKit and I haven’t found any overridden method (including private ones) of NSView and only a few of completely unrelated classes (like -(BOOL)isVIsible, for example). “-(void)drawFocusRing" is defined for usage with some custom NSView subclasses spread all over through the application, to make them draw their specific focus ring.
> these changes in the category apply to ALL views, including your NSButtons.
Yeah, I know that.
> You could verify very simply by setting a breakpoint in your “drawFocusRing” method, and see if one of your buttons actually executes this method instead of the original.
Nope, unfortunately it’s not that easy. Also, like I’ve mentioned in the first post in this thread, just defining simple NSAlert with default three buttons (so, they are completely drawn by the AppKit and should not use any added methods of my category) causes corresponding alert panel to draw its buttons without a focus ring.
> It is not recommended to mess with the NSView or NSWindow behavior, because we don’t know what Apple is doing in their implementation.
Well, the application is not that simple and requires a lot of things APIs don’t provide out-of-the-box. Also, I don’t see defining unique methods in a NSView category like messing with NSView behaviour. Something is certainly messed up, but I don’t see this category being the reason. If I’m wrong I’d be really thankful if someone pinpoints errors in the provided code.
-- Dragan
_______________________________________________
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