mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2026-04-02 09:30: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(
|
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() {
|
func addPhpActionMenuItems() {
|
||||||
|
|||||||
@@ -26,11 +26,17 @@ struct HeaderView: View {
|
|||||||
|
|
||||||
static func asMenuItem(
|
static func asMenuItem(
|
||||||
text: String,
|
text: String,
|
||||||
width: Int? = nil
|
minimumWidth: CGFloat? = nil
|
||||||
) -> NSMenuItem {
|
) -> NSMenuItem {
|
||||||
let view = NSHostingView(rootView: Self(text: text))
|
let view = NSHostingView(rootView: Self(text: text))
|
||||||
view.autoresizingMask = [.width, .height]
|
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()
|
let item = NSMenuItem()
|
||||||
item.view = view
|
item.view = view
|
||||||
|
|||||||
Reference in New Issue
Block a user