From 6c67544c714ea989321336b02cc65b20b129ca4d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Wed, 31 Aug 2022 13:21:13 -0500 Subject: [PATCH] moved tap back into each control since not all controls should need this Signed-off-by: Matt Bruce --- VDS/Classes/Control.swift | 6 ------ VDS/Components/Checkbox/Checkbox.swift | 7 ++++++- VDS/Components/RadioBox/RadioBox.swift | 5 +++++ VDS/Components/RadioButton/RadioButton.swift | 6 +++++- VDS/Components/RadioSwatch/RadioSwatch.swift | 9 +++++++-- VDS/Components/RadioSwatch/RadioSwatchGroup.swift | 2 +- VDS/Components/Toggle/Toggle.swift | 7 ++++++- 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 735db1cb..8ae59708 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -27,7 +27,6 @@ open class Control: UIControl, ModelHandlerable, ViewProto //if set to true this will call the //defaultAction() in the class public var executeDefaultAction = true - public var isTappable = true @Proxy(\.model.surface) open var surface: Surface @@ -84,7 +83,6 @@ open class Control: UIControl, ModelHandlerable, ViewProto initialSetupPerformed = true setupUpdateView() setup() - if isTappable { addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap))) } } } @@ -104,10 +102,6 @@ open class Control: UIControl, ModelHandlerable, ViewProto defaultAction() } } - - @objc func tap() { - sendActions(for: .touchUpInside) - } open func defaultAction() { } diff --git a/VDS/Components/Checkbox/Checkbox.swift b/VDS/Components/Checkbox/Checkbox.swift index 7949ecc1..2733765b 100644 --- a/VDS/Components/Checkbox/Checkbox.swift +++ b/VDS/Components/Checkbox/Checkbox.swift @@ -127,7 +127,8 @@ open class CheckboxBase: Control, Changable open override func setup() { super.setup() - + addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap))) + isAccessibilityElement = true accessibilityTraits = .button addSubview(mainStackView) @@ -204,6 +205,10 @@ open class CheckboxBase: Control, Changable onChange = nil } + @objc func tap() { + sendActions(for: .touchUpInside) + } + /// This will checkbox the state of the Selector and execute the actionBlock if provided. open override func defaultAction() { //removed error diff --git a/VDS/Components/RadioBox/RadioBox.swift b/VDS/Components/RadioBox/RadioBox.swift index c71728a3..99302e51 100644 --- a/VDS/Components/RadioBox/RadioBox.swift +++ b/VDS/Components/RadioBox/RadioBox.swift @@ -128,6 +128,7 @@ open class RadioBoxBase: Control, Changable open override func setup() { super.setup() + addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap))) isAccessibilityElement = true accessibilityTraits = .button @@ -202,6 +203,10 @@ open class RadioBoxBase: Control, Changable setAccessibilityLabel() onChange = nil } + + @objc func tap() { + sendActions(for: .touchUpInside) + } /// This will radioBox the state of the Selector and execute the actionBlock if provided. open override func defaultAction() { diff --git a/VDS/Components/RadioButton/RadioButton.swift b/VDS/Components/RadioButton/RadioButton.swift index 46eabdee..aff7525f 100644 --- a/VDS/Components/RadioButton/RadioButton.swift +++ b/VDS/Components/RadioButton/RadioButton.swift @@ -126,7 +126,8 @@ open class RadioButtonBase: Control, Cha open override func setup() { super.setup() - + addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap))) + isAccessibilityElement = true accessibilityTraits = .button addSubview(mainStackView) @@ -203,6 +204,9 @@ open class RadioButtonBase: Control, Cha onChange = nil } + @objc func tap() { + sendActions(for: .touchUpInside) + } /// This will checkbox the state of the Selector and execute the actionBlock if provided. open override func defaultAction() { diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index c5091a92..1f433afb 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -88,7 +88,8 @@ open class RadioSwatchBase: Control, Cha open override func setup() { super.setup() - + addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap))) + isAccessibilityElement = true accessibilityTraits = .button addSubview(selectorView) @@ -120,7 +121,11 @@ open class RadioSwatchBase: Control, Cha setAccessibilityLabel() onChange = nil } - + + @objc func tap() { + sendActions(for: .touchUpInside) + } + open override func defaultAction() { isSelected.toggle() sendActions(for: .valueChanged) diff --git a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift index c892dc8e..6340d613 100644 --- a/VDS/Components/RadioSwatch/RadioSwatchGroup.swift +++ b/VDS/Components/RadioSwatch/RadioSwatchGroup.swift @@ -96,7 +96,7 @@ public class RadioSwatchGroupBase: Control, Changable { //-------------------------------------------------- open override func setup() { super.setup() + addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(Self.tap))) isAccessibilityElement = true accessibilityTraits = .button @@ -309,7 +310,11 @@ open class ToggleBase: Control, Changable { setAccessibilityLabel() onChange = nil } - + + @objc func tap() { + sendActions(for: .touchUpInside) + } + /// This will toggle the state of the Toggle and execute the actionBlock if provided. open override func defaultAction() { isOn.toggle()