mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 03:50:08 +02:00
🐛 Fix issue with minimum width w/ hidden UI
This commit is contained in:
@ -19,8 +19,9 @@ extension StatusMenu {
|
||||
}
|
||||
|
||||
addItem(HeaderView.asMenuItem(
|
||||
text: "\("mi_php_version".localized) \(PhpEnv.phpInstall.version.long)")
|
||||
)
|
||||
text: "\("mi_php_version".localized) \(PhpEnv.phpInstall.version.long)",
|
||||
minimumWidth: 280 // this ensures the menu is at least wide enough not to cause clipping
|
||||
))
|
||||
}
|
||||
|
||||
func addPhpActionMenuItems() {
|
||||
|
@ -26,11 +26,17 @@ struct HeaderView: View {
|
||||
|
||||
static func asMenuItem(
|
||||
text: String,
|
||||
width: Int? = nil
|
||||
minimumWidth: CGFloat? = nil
|
||||
) -> NSMenuItem {
|
||||
let view = NSHostingView(rootView: Self(text: text))
|
||||
view.autoresizingMask = [.width, .height]
|
||||
view.setFrameSize(CGSize(width: view.frame.width, height: 24))
|
||||
|
||||
var finalWidth = view.frame.width
|
||||
if minimumWidth != nil && minimumWidth! > finalWidth {
|
||||
finalWidth = minimumWidth!
|
||||
}
|
||||
|
||||
view.setFrameSize(CGSize(width: finalWidth, height: 24))
|
||||
|
||||
let item = NSMenuItem()
|
||||
item.view = view
|
||||
|
Reference in New Issue
Block a user