cocoabits / MASShortcut

Modern framework for managing global keyboard shortcuts compatible with Mac App Store. More details:
http://blog.shpakovski.com/2012/07/global-keyboard-shortcuts-in-cocoa.html
BSD 2-Clause "Simplified" License
1.52k stars 220 forks source link

Autolayout issue #124

Closed ttscoff closed 5 years ago

ttscoff commented 5 years ago

I'm attempting to instantiate a MASShortcutView programmatically and insert into an autolayout stack. The button always shows up with the view slightly short so the top and bottom lines of the button are cut off. Any chance of a fix for the intrinsic size of the view?

shpakovski commented 5 years ago

Hi Brett, does heightAnchor help?

fletcher commented 5 years ago

Hi. I'm working with Brett on this project. I'll take a look at heightAnchor, but is it correct that the MASShortcutView doesn't have an intrinsic size that provides a minimum height? Putting the MASShortcutView inside of an NSStackView with other items (e.g. NSTextField, NSButton, etc.) results in a view that shows everything else, but the MASShortcutView ends up with a height of 0, making it invisible. Forcing the NSStackView to be taller (by adding a second column with more content) makes the MASShortcutView visible, assuming there is enough room. Attempting to set the frameSize directly did not work.

Thanks!!

shpakovski commented 5 years ago

Hey Fletcher, that’s right. Auto Layout was introduced later than MASShortcut was born. Maybe frameSize works if you disable translating autoresizing masks into constraints?

fletcher commented 5 years ago

So is there any reason not to provide an intrinsicContentSize to make MASShortcutView more compatible with auto layout?

shpakovski commented 5 years ago

The intrinsic content size is depending on the control style which may influent the cell appearance. If handled properly, it can definitely be implemented. Pull Request is welcome 👌

fletcher commented 5 years ago

Done.

zoul commented 5 years ago

Merged in #125, thank you!