[NUI] Delegate Button.OnAccessibilityActivated() to OnKey() (#2699)
authorArtur Świgoń <aswigon@yandex.com>
Fri, 5 Mar 2021 01:32:21 +0000 (02:32 +0100)
committerhuiyueun <35286162+huiyueun@users.noreply.github.com>
Mon, 8 Mar 2021 08:29:15 +0000 (17:29 +0900)
This commit fixes a bug where it was possible to select multiple radio
buttons from one RadioButtonGroup in accessibility (screen reader) mode.

OnAccessibilityActivated() contained code copied from OnKey(). However,
some classes derived from Button override OnKey(), e.g. SelectButton
makes sure that other buttons in the group are unselected if necessary.
Rather than overriding OnAccessibilityActivated() in derived classes, it
is better to invoke OnKey() instead, in order to reduce code
duplication.

Note: this change matches the corresponding logic in DALi Toolkit, where
OnAccessibilityActivated() is implemented in terms of OnKeyboardEnter().

Co-authored-by: Artur Świgoń <a.swigon@samsung.com>
src/Tizen.NUI.Components/Controls/Button.Internal.cs

index 645e5af..11171c4 100755 (executable)
@@ -484,33 +484,19 @@ namespace Tizen.NUI.Components
 
         internal override bool OnAccessibilityActivated()
         {
 
         internal override bool OnAccessibilityActivated()
         {
-            if (!IsEnabled)
+            using (var key = new Key())
             {
             {
-                return false;
-            }
+                key.State = Key.StateType.Down;
+                key.KeyPressedName = "Return";
 
 
-            // Touch Down
-            isPressed = true;
-            UpdateState();
+                // Touch Down
+                OnKey(key);
 
 
-            // Touch Up
-            bool clicked = isPressed && IsEnabled;
-            isPressed = false;
-
-            if (IsSelectable)
-            {
-                IsSelected = !IsSelected;
-            }
-            else
-            {
-                UpdateState();
+                // Touch Up
+                key.State = Key.StateType.Up;
+                OnKey(key);
             }
 
             }
 
-            if (clicked)
-            {
-                ClickedEventArgs eventArgs = new ClickedEventArgs();
-                OnClickedInternal(eventArgs);
-            }
             return true;
         }
 
             return true;
         }