From ba1eed7a85dcbfac371b17e8298e02c55854e1d6 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 13 Dec 2022 20:36:18 -0500 Subject: [PATCH] Add pointer effect to custom alert actions Closes #306 --- .../Screens/Utilities/CustomAlertController.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Tusker/Screens/Utilities/CustomAlertController.swift b/Tusker/Screens/Utilities/CustomAlertController.swift index d13288ff..67469a32 100644 --- a/Tusker/Screens/Utilities/CustomAlertController.swift +++ b/Tusker/Screens/Utilities/CustomAlertController.swift @@ -394,6 +394,8 @@ class CustomAlertActionButton: UIControl { self.isContextMenuInteractionEnabled = true self.showsMenuAsPrimaryAction = action.handler == nil } + + addGestureRecognizer(UIHoverGestureRecognizer(target: self, action: #selector(hoverRecognized))) } required init?(coder: NSCoder) { @@ -429,6 +431,17 @@ class CustomAlertActionButton: UIControl { super.contextMenuInteraction(interaction, willEndFor: configuration, animator: animator) } + @objc func hoverRecognized(_ recognizer: UIHoverGestureRecognizer) { + switch recognizer.state { + case .began, .changed: + backgroundColor = .secondarySystemFill + case .ended: + backgroundColor = nil + default: + break + } + } + override func touchesBegan(_ touches: Set, with event: UIEvent?) { super.touchesBegan(touches, with: event)