4

How can you get an NSButton to detach from an NSStackView when the stack view resizes?

NSControl subclasses that use NSCell drawing seem to have a different mind than other NSView subclasses on visibility with compression resistance in Auto Layout. NSStackView doesn't seem to make a difference here either.

If I set the Visibility Priority for a control higher than 1, it will not drop. If I set it to 0, well, of course it will only drop and never appear.

How is this supposed to work?
What does it take to get a button or other control to drop when the stack view is resized smaller?
Maybe it's the dearth of docs and examples of NSStackView...

Jay
  • 6,572
  • 3
  • 37
  • 65
uchuugaka
  • 12,679
  • 6
  • 37
  • 55
  • 2
    +1 for being bold and wrestling with that new `NSStackView` thingie - and the first SO stack view question :-) – Jay Jan 13 '14 at 17:50

2 Answers2

2

Before I saw any views detach, I had to do two things:

  1. Call -[NSStackView setClippingResistancePriority:forOrientation:]. If the size of the stack view is tied to the size of the window, the priority needs to be less than NSLayoutPriorityWindowSizeStayPut (500) or the stack view doesn't allow the window to get smaller than its content.

  2. Each time I added a view to the stack view that I wanted to detach, call -[NSStackView setVisibilityPriority:forView:] for that view.

s4y
  • 50,525
  • 12
  • 70
  • 98
0

Try setting the priority to NSStackViewVisibilityPriorityDetachOnlyIfNecessary?

Wil Shipley
  • 9,343
  • 35
  • 59
  • Nope. Sits there like a button does when it's constrained to both sides of a split view sub view and you drag the divider. I'm guessing there's some trick to constraint priorities next. – uchuugaka Jan 14 '14 at 11:42