fix: avoid crashing in rare cases
This commit is contained in:
1 parent
8abb9b4358
commit
9980ec62fd
2 files changed
+17
-11
No files matched your search
@@ -138,6 +138,7 @@ They helped [localize the app](https://poeditor.com/join/project/8AOEZ0eAZE):
|
||||
* Lcwhhh
|
||||
* Lester
|
||||
* Loïc
|
||||
* Loic. peron
|
||||
* LostInCompilation
|
||||
* Lumaxis
|
||||
* lwouis
|
||||
@@ -197,6 +198,7 @@ They helped [localize the app](https://poeditor.com/join/project/8AOEZ0eAZE):
|
||||
* shlomo
|
||||
* Sippawit Thammawiset
|
||||
* Sjur Moshagen
|
||||
* Sjur.n. moshagen
|
||||
* Stan Smits
|
||||
* Stefan
|
||||
* Svetoslav Stefanov
|
||||
|
||||
@@ -15,16 +15,20 @@ class PopupButtonLikeSystemSettings: NSPopUpButton {
|
||||
}
|
||||
|
||||
override var intrinsicContentSize: NSSize {
|
||||
let fakePopUpButton = NSPopUpButton()
|
||||
fakePopUpButton.addItem(withTitle: title)
|
||||
fakePopUpButton.selectedItem!.image = selectedItem!.image
|
||||
let fakeCell = fakePopUpButton.cell! as! NSPopUpButtonCell
|
||||
let currentCell = cell! as! NSPopUpButtonCell
|
||||
fakeCell.bezelStyle = currentCell.bezelStyle
|
||||
fakeCell.arrowPosition = currentCell.arrowPosition
|
||||
fakeCell.imagePosition = currentCell.imagePosition
|
||||
fakePopUpButton.showsBorderOnlyWhileMouseInside = showsBorderOnlyWhileMouseInside
|
||||
fakePopUpButton.sizeToFit()
|
||||
return fakePopUpButton.intrinsicContentSize
|
||||
if let selectedItem = selectedItem {
|
||||
let fakePopUpButton = NSPopUpButton()
|
||||
fakePopUpButton.addItem(withTitle: title)
|
||||
fakePopUpButton.item(at: 0)!.image = selectedItem.image
|
||||
let fakeCell = fakePopUpButton.cell! as! NSPopUpButtonCell
|
||||
let currentCell = cell! as! NSPopUpButtonCell
|
||||
fakeCell.bezelStyle = currentCell.bezelStyle
|
||||
fakeCell.arrowPosition = currentCell.arrowPosition
|
||||
fakeCell.imagePosition = currentCell.imagePosition
|
||||
fakePopUpButton.showsBorderOnlyWhileMouseInside = showsBorderOnlyWhileMouseInside
|
||||
fakePopUpButton.sizeToFit()
|
||||
return fakePopUpButton.intrinsicContentSize
|
||||
} else {
|
||||
return super.intrinsicContentSize
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user