2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using Tizen.NUI.BaseComponents;
19 using System.ComponentModel;
21 namespace Tizen.NUI.Components
24 /// SelectButton is base class of CheckBox and RadioButton.
25 /// It can be used as selector and add into group for single-choice or multiple-choice .
26 /// User can handle Navigation by adding/inserting/deleting NavigationItem.
28 /// <since_tizen> 6 </since_tizen>
29 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
30 [EditorBrowsable(EditorBrowsableState.Never)]
31 public class SelectButton : Button
33 private SelectGroup itemGroup = null;
36 /// Item group which is used to manager all SelectButton in it.
38 /// <since_tizen> 6 </since_tizen>
39 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
40 [EditorBrowsable(EditorBrowsableState.Never)]
41 protected SelectGroup ItemGroup { get => itemGroup; set => itemGroup = value; }
43 static SelectButton() { }
46 /// Creates a new instance of a SelectButton.
48 /// <since_tizen> 6 </since_tizen>
49 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
50 [EditorBrowsable(EditorBrowsableState.Never)]
51 public SelectButton() : base()
56 /// Creates a new instance of a SelectButton with style.
58 /// <param name="style">Create SelectButton by special style defined in UX.</param>
59 /// <since_tizen> 6 </since_tizen>
60 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
61 [EditorBrowsable(EditorBrowsableState.Never)]
62 public SelectButton(string style) : base(style)
67 /// Creates a new instance of a SelectButton with style.
69 /// <param name="buttonStyle">Create SelectButton by style customized by user.</param>
70 /// <since_tizen> 6 </since_tizen>
71 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
72 [EditorBrowsable(EditorBrowsableState.Never)]
73 public SelectButton(ButtonStyle buttonStyle) : base(buttonStyle)
78 /// An event for the item selected signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
80 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
81 [EditorBrowsable(EditorBrowsableState.Never)]
82 public event EventHandler<SelectedChangedEventArgs> SelectedChanged;
85 /// Index of selection in selection group. If selection is not in the group, return -1;
87 /// <since_tizen> 6 </since_tizen>
88 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
89 [EditorBrowsable(EditorBrowsableState.Never)]
94 if (ItemGroup != null)
96 return ItemGroup.GetIndex(this);
104 [EditorBrowsable(EditorBrowsableState.Never)]
105 public override void OnInitialize()
112 /// Dispose SelectButton and all children on it.
114 /// <param name="type">Dispose type.</param>
115 /// <since_tizen> 6 </since_tizen>
116 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
117 [EditorBrowsable(EditorBrowsableState.Never)]
118 protected override void Dispose(DisposeTypes type)
125 if (type == DisposeTypes.Explicit)
134 /// Called after a key event is received by the view that has had its focus set.
136 /// <param name="key">The key event.</param>
137 /// <returns>True if the key event should be consumed.</returns>
138 /// <since_tizen> 6 </since_tizen>
139 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public override bool OnKey(Key key)
143 if ((IsEnabled == false) || (key == null))
148 return base.OnKey(key);
152 /// Called after a touch event is received by the owning view.<br />
153 /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
155 /// <param name="touch">The touch event.</param>
156 /// <returns>True if the event should be consumed.</returns>
157 /// <since_tizen> 6 </since_tizen>
158 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
159 [EditorBrowsable(EditorBrowsableState.Never)]
160 public override bool OnTouch(Touch touch)
162 return base.OnTouch(touch);
166 [EditorBrowsable(EditorBrowsableState.Never)]
167 protected override bool HandleControlStateOnTouch(Touch touch)
169 if ((IsEnabled == false) || (touch == null))
174 return base.HandleControlStateOnTouch(touch);
178 /// Overrides this method if want to handle behavior after pressing return key by user.
180 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
181 [EditorBrowsable(EditorBrowsableState.Never)]
182 protected virtual void OnSelectedChanged()
187 [EditorBrowsable(EditorBrowsableState.Never)]
188 protected override void OnControlStateChanged(ControlStateChangedEventArgs info)
190 if (info.PreviousState.Contains(ControlState.Selected) != info.CurrentState.Contains(ControlState.Selected))
192 if (Accessibility.Accessibility.IsEnabled && IsHighlighted)
194 EmitAccessibilityStateChangedEvent(AccessibilityState.Checked, info.CurrentState.Contains(ControlState.Selected));
199 if (SelectedChanged != null)
201 SelectedChangedEventArgs eventArgs = new SelectedChangedEventArgs();
202 eventArgs.IsSelected = IsSelected;
203 SelectedChanged(this, eventArgs);
208 internal void RemoveFromGroup() => itemGroup?.RemoveSelection(this);
210 internal void ResetItemGroup() => itemGroup = null;