Submenu in the HUD panel

I am working on OSX 10.10
I am facing a strange issue with the color of the subviews inverted for the HUD bar.
For example, a button when the default button is set looks right in the Xib file, but when it runs, the view button is changed by the HUD button.

I have a HUD bar in my Xib file as follows enter image description here


But on execution, the button loses its default button status. It looks like this After exxecution

How to keep the appearance of the button after execution. The user is unable to determine which action will be the default due to this appearance.

+3


source to share


2 answers


Try



_defaultButton.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];

      

+1


source


The Builder interface follows a set of rules, but these rules are context independent. The context I'm talking about is "displayed in the HUD".

The rule of thumb in this case is "draw a blue button in the Interface Builder if the button is the default button", even if that's not always what happens (see what you see in the second screenshot).

I don't know which version of OS X it works like this, but now the controls in the HUD panels are rendered with a different style (which doesn't have a specific color for the default button).

You can validate this Interface Builder by adding a simple one NSTextField

to your HUD panel, it will draw with a white background in the Interface Builder, but when working with a gray focus ring, it will have a black background.

Interface constructor:

Interface builder

OS X 10.10:

OS X 10.10

I've never found a way to disable this special styling for controls in the HUD, but there are a few workarounds (the default button still works correctly even if it doesn't have a custom color).



The custom style is only applied when the HUD has a title bar.

self.panel.styleMask = (NSHUDWindowMask | NSTitledWindowMask | NSUtilityWindowMask | NSNonactivatingPanelMask);

      

If you remove the title bar, it displays without any special styling:

self.panel.styleMask = (NSHUDWindowMask | NSUtilityWindowMask | NSNonactivatingPanelMask);

      

HUD Panel without a title bar

At this point, you can implement and draw your own title bar in the bar and simulate the default. I don't really like this approach because it works on a simple button at first, and the custom styling of the controls makes them look nicer and easier to read in the HUD.

Another solution was "VLC". They use HUD panels, but their controls are not specifically styled. They use the BGHUDAppKit

one that was released when Apple provided the HUD without any special controls. They use it to force a bluish style instead of the gray that is now the default in HUD panels. I didn't like this approach either, I didn't want to add a library for a simple button, the library hasn't been updated since 2011.

As a result, I created a custom button (with a simple subclass) for the default buttons in the HUD. This solution is quick and lets you pick the color you want for the default button on the HUD (blue might not be the best for the HUD, your challenge).

+1


source







All Articles