quirky default button coloring

  • From what I read, the default (button in a view is outlined/shaded
    in blue and is set as the button which responds to RETURN. I have a
    serious of buttons (step 1, step 2, etc.), and I want the appropriate
    button to be highlighted as the default when it is turn to do that
    step. I used this code within a "showWindow" method which loads the
    window.

    int stepsCompleted = [[dataValues objectForKey: @"steps completed"]
    intValue];

      switch (stepsCompleted)
      {
      case 0:
        [step1Button setKeyEquivalent:@"\r"];
          break;

      case 1:
        [step2Button setKeyEquivalent:@"\r"]; // works
        [step1Button setKeyEquivalent:@""]; // but blue edge does not
    move to button 2
      break;
    ....

    From When I do this, the correct button does indeed respond to
    RETURN. But the blue highlight remains on the first button. I also
    tried [<button> setHighlight: <YES/NO>] to control the highlighting
    state, but with square buttons that simply makes them a dark grey and
    does not affect the blue outline.

              In the nib, all of the buttons are marked as having no key
    equivalent. I should note that I am using the square button shape. Is
    this a bug?
  • Hi Daniel.

    I think you're confusing the focus ring with the default button.

    Default button:
    http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGui
    delines/XHIGControls/chapter_19_section_3.html#//apple_ref/doc/uid/TP300003
    59-DontLinkElementID_446


    Focus ring:
    http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGui
    delines/XHIGUserInput/chapter_12_section_3.html//apple_ref/doc/uid/TP300003
    61-BJCFCJAF


    The only button that draws differently when its key equivalent is
    return is the standard push button like you see in alerts.  "OK" is
    often the text on the button.  The pulsing blue animation is how the
    user knows it is default.

    The focus ring is different.  You move focus from control to control
    with the tab key, and the space bar will activate the control that has
    the ring around it.  The user can only tab to a button if he has
    selected the "All controls" option for "In windows and dialogs, press
    Tab to move the keyboard focus between:" in the Keyboard & Mouse
    preference pane.

    Default buttons should probably always be the standard aqua glassy
    style (which is NSRoundedBezelStyle if you're making 'em in code).
    There are a few counterexamples in Apple apps, but it's not clear that
    those cases were a good idea.

    'Highlighted' for a button means, pressed, by the way.  You told your
    buttons to draw their pressed art.

    -Ken

    On Thu, Feb 21, 2008 at 11:55 AM, Daniel Child <wchild...> wrote:
    > From what I read, the default (button in a view is outlined/shaded
    > in blue and is set as the button which responds to RETURN. I have a
    > serious of buttons (step 1, step 2, etc.), and I want the appropriate
    > button to be highlighted as the default when it is turn to do that
    > step. I used this code within a "showWindow" method which loads the
    > window.
    >
    > int stepsCompleted = [[dataValues objectForKey: @"steps completed"]
    > intValue];
    >
    > switch (stepsCompleted)
    > {
    > case 0:
    > [step1Button setKeyEquivalent:@"\r"];
    > break;
    >
    > case 1:
    > [step2Button setKeyEquivalent:@"\r"]; // works
    > [step1Button setKeyEquivalent:@""]; // but blue edge does not
    > move to button 2
    > break;
    > ....
    >
    > From When I do this, the correct button does indeed respond to
    > RETURN. But the blue highlight remains on the first button. I also
    > tried [<button> setHighlight: <YES/NO>] to control the highlighting
    > state, but with square buttons that simply makes them a dark grey and
    > does not affect the blue outline.
    >
    > In the nib, all of the buttons are marked as having no key
    > equivalent. I should note that I am using the square button shape. Is
    > this a bug?
    >
  • You were absolutely right. Thanks. A shame that push button is the
    only one that provides this colored behavior for default. I could see
    it being useful.

    On Feb 21, 2008, at 3:29 PM, Ken Ferry wrote:

    > I think you're confusing the focus ring with the default button.
  • You're right it turned out to be a focus issue.

    I was looking into FirstResponder (before posting the question but it
    didn't seem right), but as Ken Ferry pointed out, the issue was
    actually on my computer: a preference setting where focus moves to
    all objects, not just text fields. Plus the fact that default-blue
    shading only goes on PushButtons. The code itself was fine. Thanks.

    On Feb 21, 2008, at 4:14 PM, Matt Gray wrote:

    > I think the blue outline you are seeing is indicating which button
    > has focus at the moment - it is the 'first responder' for the
    > window.  Perhaps try changing the first responder
    > (setFirstResponder or something like that, I can't remember
    > exactly).  It seems that changing the key equivalent won't change
    > the first responder.
    >
    > Hope that helps (but I could be way off. ;-) )
previous month february 2008 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29    
Go to today