Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSToolbar - Toolbar Space Item - breaking default constraints

If i change the size of NSToolbar from application, via small size, icons & text, the app brakes on unsatisfied constraints (tried to turn off autolayout, or let the app generate its layout)

My window consist of a toolbar and a (left / right) split view inside

[81687:303] Unable to simultaneously satisfy constraints:
(
    "<NSAutoresizingMaskLayoutConstraint:0x100635620 h=--& v=--& V:[NSToolbarItemViewer:0x101b4d930(5)]>",
    "<NSAutoresizingMaskLayoutConstraint:0x100634b30 h=--& v=-&- V:|-(11)-[_NSToolbarSpace:0x101b49a00]   (Names: '|':NSToolbarItemViewer:0x101b4d930 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x100634ad0 h=--& v=-&- V:[_NSToolbarSpace:0x101b49a00]-(12)-|   (Names: '|':NSToolbarItemViewer:0x101b4d930 )>"
)

Will attempt to recover by breaking constraint 
<NSAutoresizingMaskLayoutConstraint:0x100634b30 h=--& v=-&- V:|-(11)-[_NSToolbarSpace:0x101b49a00]   (Names: '|':NSToolbarItemViewer:0x101b4d930 )>

Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens.  And/or, break on objc_exception_throw to catch this in the debugger.

When i visualize the constraint error

enter image description here

Edit : Looks like "Toolbar Space Item" is breaking the constraint, if i remove it, i runs fine

like image 500
Peter Lapisu Avatar asked Oct 15 '13 14:10

Peter Lapisu


2 Answers

Looks like a bug, i ended up adding my own space item, using a blank NSView

like image 93
Peter Lapisu Avatar answered Oct 17 '22 23:10

Peter Lapisu


I had a similar problem. And what fixed the problem for me was removing all flexible spaces from both the Default Toolbar and the Allowed Toolbar Items. When I added the Flexible Space again from the object browser the warning disappeared.

In my Git diff I see that the structure seems to have changed somewhat:

git diff

like image 3
Besi Avatar answered Oct 18 '22 00:10

Besi