What is the best way to create a stop motion button, for example in a Safari download window?

The Apple Human Interface Guide says:

In the Downloads window, Safari uses the stand-alone NSImageNameStopProgressFreestandingTemplate image, which is built into the progress indicator so that users can stop the current download.

Safari Downloads Window
(source: apple.com )

The NSImage documentation says something similar. However, creating an NSButton using NSImageNameStopProgressFreestandingTemplate and NSShadowlessSquareBezelStyle results in something like this:

NSImageNameStopProgressFreestandingTemplate

Unfortunately, this button does not match the Stop Execution buttons for Mac OS X embedded applications:

  1. It is much darker than the buttons in Finder and Safari, and slightly darker than the button in iCal.
  2. It does not change color on hover / hover like buttons in Finder, Safari and iCal.

Are you missing the NSButton setting that NSButton system image look β€œcorrect”?

If this fails, is it better to use the NSImageNameStopProgressFreestandingTemplate and look "wrong", or write a subclass of the button and link some TIFF files, which is what most applications (including Apple) seem to do?

+4
source share
2 answers

The official answer on Mac OS X 10.7 is to use NSImageNameStopProgressFreestandingTemplate and NSInlineBezelStyle . The documentation says:

The linear style of the frame contains a solid rectangular border background. It can be used to create an β€œunread” indicator in the form of a contour or another built-in button in the form of a table, for example, a stop button on the download panel.

This creates a button that is slightly darker than Safari, but not as dark as other border styles. It does not change color on hover, but perhaps Apple is gradually abandoning it.

+2
source

The docs on [NSImage setTemplate:] offer a different alpha to determine how dark it is. However, I'm not sure how to do this when you are not drawing the image directly. I see no better way than writing my own subclass of NSButton or, possibly, NSButtonCell.

+1
source

Source: https://habr.com/ru/post/1312485/


All Articles