From 5bd33e1397983a3c7f773723e626da822ff3de4d Mon Sep 17 00:00:00 2001 From: stackotter Date: Mon, 20 Oct 2025 14:24:28 +1000 Subject: [PATCH 1/3] Fix Mac Catalyst button support (respect interface idiom) --- Sources/UIKitBackend/UIKitBackend+Control.swift | 5 +++-- Sources/UIKitBackend/UIKitBackend.swift | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/UIKitBackend/UIKitBackend+Control.swift b/Sources/UIKitBackend/UIKitBackend+Control.swift index 68816b02dd..0b7a680a9f 100644 --- a/Sources/UIKitBackend/UIKitBackend+Control.swift +++ b/Sources/UIKitBackend/UIKitBackend+Control.swift @@ -23,7 +23,7 @@ final class ButtonWidget: WrapperWidget { type = .system event = .primaryActionTriggered #else - type = .custom + type = .system event = .touchUpInside #endif super.init(child: UIButton(type: type)) @@ -268,7 +268,8 @@ extension UIKitBackend { UIKitBackend.attributedString( text: label, environment: environment, - defaultForegroundColor: .link + // Handle Mac Catalyst + defaultForegroundColor: deviceClass == .desktop ? .label : .link ), for: .normal ) diff --git a/Sources/UIKitBackend/UIKitBackend.swift b/Sources/UIKitBackend/UIKitBackend.swift index f7580a6a06..97559a4acd 100644 --- a/Sources/UIKitBackend/UIKitBackend.swift +++ b/Sources/UIKitBackend/UIKitBackend.swift @@ -48,6 +48,10 @@ public final class UIKitBackend: AppBackend { public init() { self.appDelegateClass = ApplicationDelegate.self + print(UIDevice.current.userInterfaceIdiom == .pad) + if #available(macCatalyst 14.0, *) { + print(UIDevice.current.userInterfaceIdiom == .mac) + } } public init(appDelegateClass: ApplicationDelegate.Type) { From 5060d9c77356d463717ad28cc550a53a2539a796 Mon Sep 17 00:00:00 2001 From: stackotter Date: Mon, 20 Oct 2025 14:27:19 +1000 Subject: [PATCH 2/3] Simplify code --- Sources/UIKitBackend/UIKitBackend+Control.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Sources/UIKitBackend/UIKitBackend+Control.swift b/Sources/UIKitBackend/UIKitBackend+Control.swift index 0b7a680a9f..e4de87544e 100644 --- a/Sources/UIKitBackend/UIKitBackend+Control.swift +++ b/Sources/UIKitBackend/UIKitBackend+Control.swift @@ -18,15 +18,12 @@ final class ButtonWidget: WrapperWidget { } init() { - let type: UIButton.ButtonType #if os(tvOS) - type = .system event = .primaryActionTriggered #else - type = .system event = .touchUpInside #endif - super.init(child: UIButton(type: type)) + super.init(child: UIButton(type: .system)) } } From cbef6f84caa5a6a815d04974b3691339a8467a2b Mon Sep 17 00:00:00 2001 From: stackotter Date: Mon, 20 Oct 2025 14:28:43 +1000 Subject: [PATCH 3/3] Remove debug prints --- Sources/UIKitBackend/UIKitBackend.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Sources/UIKitBackend/UIKitBackend.swift b/Sources/UIKitBackend/UIKitBackend.swift index 97559a4acd..f7580a6a06 100644 --- a/Sources/UIKitBackend/UIKitBackend.swift +++ b/Sources/UIKitBackend/UIKitBackend.swift @@ -48,10 +48,6 @@ public final class UIKitBackend: AppBackend { public init() { self.appDelegateClass = ApplicationDelegate.self - print(UIDevice.current.userInterfaceIdiom == .pad) - if #available(macCatalyst 14.0, *) { - print(UIDevice.current.userInterfaceIdiom == .mac) - } } public init(appDelegateClass: ApplicationDelegate.Type) {