From f38ca8697eec469a03c02978cc321c5891e3cd42 Mon Sep 17 00:00:00 2001 From: Jaehyun Cho <29364140+jaehyun0cho@users.noreply.github.com> Date: Tue, 10 Nov 2020 20:15:02 +0900 Subject: [PATCH] [NUI] Add EnableMultiSelection to SelectGroup (#2116) To support selecting multiple SelectButtons in SelectGroup, bool EnableMultiSelection is added to SelectGroup. By adding EnableMultiSelection in SelectGroup, RadioButtonGroup does not need to implement its logic to prevent selecting multiple RadioButtons. Co-authored-by: Jaehyun Cho Co-authored-by: Jiyun Yang --- .../Controls/RadioButtonGroup.cs | 26 +--------------------- src/Tizen.NUI.Components/Controls/SelectGroup.cs | 20 ++++++++++++++++- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/Tizen.NUI.Components/Controls/RadioButtonGroup.cs b/src/Tizen.NUI.Components/Controls/RadioButtonGroup.cs index 18a031d..a028465 100755 --- a/src/Tizen.NUI.Components/Controls/RadioButtonGroup.cs +++ b/src/Tizen.NUI.Components/Controls/RadioButtonGroup.cs @@ -42,6 +42,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public RadioButtonGroup() : base() { + EnableMultiSelection = false; } /// @@ -84,30 +85,5 @@ namespace Tizen.NUI.Components base.RemoveSelection(radio); radio.ItemGroup = null; } - - /// - /// Handle user's select action. Turn on check state of selected RadioButton, - /// and turn out check state of other RadioButtons in RadioButtonGroup - /// - /// The selection selected by user - /// 6 - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - protected override void SelectionHandler(SelectButton selection) - { - RadioButton radio = selection as RadioButton; - if (!ItemGroup.Contains(radio)) - { - return; - } - - foreach (RadioButton btn in ItemGroup) - { - if (btn != null && btn != radio && btn.IsEnabled == true) - { - btn.IsSelected = false; - } - } - } } } diff --git a/src/Tizen.NUI.Components/Controls/SelectGroup.cs b/src/Tizen.NUI.Components/Controls/SelectGroup.cs index 9b39097..01c638d 100755 --- a/src/Tizen.NUI.Components/Controls/SelectGroup.cs +++ b/src/Tizen.NUI.Components/Controls/SelectGroup.cs @@ -70,6 +70,12 @@ namespace Tizen.NUI.Components public int SelectedIndex => selectedIndex; /// + /// EnableMultiSelection is used to indicate if SelectGroup can select multiple SelectButtons. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public bool EnableMultiSelection { get; set; } = true; + + /// /// Construct SelectionGroup /// /// 6 @@ -142,7 +148,7 @@ namespace Tizen.NUI.Components } /// - /// Overrides this method if want to handle behavior after pressing return key by user. + /// Called when the state of Selected is changed. /// /// The selection selected by user /// 6 @@ -160,6 +166,18 @@ namespace Tizen.NUI.Components if (args.IsSelected == true) { selectedIndex = selection.Index; + + if (EnableMultiSelection == false) + { + foreach (SelectButton btn in ItemGroup) + { + if ((btn != null) && (btn != selection) && (btn.IsEnabled == true) && (btn.IsSelected == true)) + { + btn.IsSelected = false; + } + } + } + SelectionHandler(selection); } } -- 2.7.4