timthedevguy / BGHUDAppKit

* BGHUDAPPKIT is no longer under development by me, I hope that the community will keep it alive and going as I no longer have time to dedicate to the project** The missing HUD controls. Please scroll down to read the readme file for an important notice concerning the future of BGHUDAppKit. Note that there are multiple versions available, 10.5+, 10.6.7, and now 10.7. As soon as I learn how I'll make these all one code base if possible.
http://www.binarymethod.com/
312 stars 57 forks source link

Full Keyboard Access #29

Closed frankrei closed 13 years ago

frankrei commented 14 years ago

Hi,

I'm having some issues where the keyboard loop (tabbing between different buttons) seems to be broken even if "Full keyboard access" switched on.

It could just be my code, but usually the "automatically recalculate keyboard loop" feature does an okay job at wiring up everything correctly.

My question: "Is BGHUDAppKit" fully keyboard accessible like the standard Mac OS X buttons and controls? If not what needs to be done to get it to work?".

Thanks for making this cool framework available.

timthedevguy commented 14 years ago

Test your code using standard controls, I'm pretty sure you will have the same issues, I've found that checking Auto Recalculate in the Window settings doesn't always work as expected. Do a manual recalculate. The reason I say try this with normal controls is because BGHUDAppKit doesn't do anything to the function of the controls, just the appearance, so please let me know if your test fails, that way I can figure out why behavior is being modified and not just appearance :)

But to answer your question in quick words, yes, BGHUDAppKit should maintain all functionality of the original apple counterparts.

frankrei commented 14 years ago

I've checked and the actual problem is that the controls do not draw a "focus ring". Ie. the controls are fully functional but do not show that they are selected.

So when the user tabs through the controls it looks like nothing is happening. Actually pressing the "space" key to activate the control activated the control; the key loop is fine.

I think all you need to do is to draw the focus ring around the button in in the drawRect method if it is the first responder.

The focus ring is only displayed if the "All Controls" radio button is selected in the "Full Keyboard Access" section of the "Keyboard Shortcuts" tab of the "Keyboard" System Preferences.

frankrei commented 14 years ago

I've had a look in the source code and it seems that the problem is simply that no focus ring is being set in the -(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView method of the BGHUDButtonCell class. Just adding the call seems to produce ok-ish results:

-(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {

// Make sure our own height is right, and not using
// a NSMatrix parents height.
cellFrame.size.height = [self cellSize].height;

[NSGraphicsContext saveGraphicsState];

if([super showsFirstResponder] && [[[self controlView] window] isKeyWindow] && 
   ([self focusRingType] == NSFocusRingTypeDefault ||
    [self focusRingType] == NSFocusRingTypeExterior)) {

       [[[[BGThemeManager keyedManager] themeForKey: self.themeKey] focusRing] set];
   }

switch ([self bezelStyle]) {

    case NSTexturedRoundedBezelStyle:

        [self drawTexturedRoundedButtonInFrame: cellFrame];
        break;

    case NSRoundRectBezelStyle:

        [self drawRoundRectButtonInFrame: cellFrame];
        break;

    case NSSmallSquareBezelStyle:

        [self drawSmallSquareButtonInFrame: cellFrame];
        break;

    case NSRoundedBezelStyle:

        [self drawRoundedButtonInFrame: cellFrame];
        break;
}

if([[_normalImage name] isEqualToString: @"NSSwitch"] ||
   [[_normalImage name] isEqualToString: @"NSRadioButton"]) {

    if([self imagePosition] != NSNoImage) {

        [self drawImage: [self image] withFrame: cellFrame inView: [self controlView]];
    }
}

[NSGraphicsContext restoreGraphicsState];

}

I haven't played around a lot with it yet but it certainly makes the focus visible even if it turns out that there is still room for a bit of fine tuning in the drawing.

I hope this helps.

timthedevguy commented 14 years ago

Sure does, I'm currently in the process of changing how BGHUDAppKit draws things, I tried to draw everything within it's own bounds, afterwards I found out that alot of the specular effects, focus rings, shadows and whatnot are actually drawn in the parent view.

AlexanderWillner commented 13 years ago

Based on my experiences with https://github.com/ugol/pomodoro/ BGHUDAppKit does not support keyboard shortcuts like cmd+c or cmd+v - see https://github.com/ugol/pomodoro/issues/issue/102

timthedevguy commented 13 years ago

Alexander,

Not sure why it doesn't on your end. Works fine on my end, I made no changes to any part of the function of the control, only the drawing.

See this vid as example: http://www.binarymethod.com/Works.mov

AlexanderWillner commented 13 years ago

Interesting. This is my video: http://dl.dropbox.com/u/1358485/bugs/pomodoro/ScreenRecording.m4v

frankrei commented 13 years ago

Just a thought.. in the video you can't see the menu bar. The Command-C/ Command-V behavior relies on the items being defined in the Edit menu and connected to the first responder. You haven't deleted or "disabled" these items in any way?

AlexanderWillner commented 13 years ago

Do these screenshots help?

http://dl.dropbox.com/u/1358485/bugs/pomodoro/screenshot1.png http://dl.dropbox.com/u/1358485/bugs/pomodoro/screenshot2.png

timthedevguy commented 13 years ago

Closed