*
*/
using System.ComponentModel;
+using Tizen.NUI.BaseComponents;
namespace Tizen.NUI.Components
{
/// radio.Text = "RadioButton";
/// radio.Focusable = true;
/// </code>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
+ /// <since_tizen> 8 </since_tizen>
public class RadioButton : SelectButton
{
+ private bool selectedAgain = false;
+
static RadioButton() { }
/// <summary>
/// Creates a new instance of a RadioButton.
/// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
+ /// <since_tizen> 8 </since_tizen>
public RadioButton() : base() { }
/// <summary>
/// Creates a new instance of a RadioButton with style.
/// </summary>
/// <param name="style"></param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
+ /// <since_tizen> 8 </since_tizen>
public RadioButton(string style) : base(style) { }
/// <summary>
/// Creates a new instance of a RadioButton with style.
/// </summary>
/// <param name="buttonStyle"></param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
+ /// <since_tizen> 8 </since_tizen>
public RadioButton(ButtonStyle buttonStyle) : base(buttonStyle) { }
/// <summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public RadioButtonGroup ItemGroup
+ public new RadioButtonGroup ItemGroup
{
get
{
- return itemGroup as RadioButtonGroup;
+ return base.ItemGroup as RadioButtonGroup;
}
internal set
{
- itemGroup = value;
+ base.ItemGroup = value;
}
}
- /// <summary>
- /// Set CheckState to true after selecting RadioButton.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void ApplyStyle(ViewStyle viewStyle)
+ {
+ if (viewStyle is ButtonStyle buttonStyle)
+ {
+ if (buttonStyle.IsSelectable == null)
+ {
+ buttonStyle.IsSelectable = true;
+ }
+
+ base.ApplyStyle(buttonStyle);
+ }
+ }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override ImageView CreateIcon()
+ {
+ return new ImageView
+ {
+ PositionUsesPivotPoint = true,
+ ParentOrigin = NUI.ParentOrigin.Center,
+ PivotPoint = NUI.PivotPoint.Center,
+ WidthResizePolicy = ResizePolicyType.DimensionDependency,
+ HeightResizePolicy = ResizePolicyType.SizeRelativeToParent,
+ SizeModeFactor = new Vector3(1, 1, 1),
+ };
+ }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool OnKey(Key key)
+ {
+ if ((IsEnabled == false) || (key == null))
+ {
+ return false;
+ }
+
+ if (key.State == Key.StateType.Up)
+ {
+ if (key.KeyPressedName == "Return")
+ {
+ if (IsSelected == true)
+ {
+ selectedAgain = true;
+ }
+ }
+ }
+
+ bool ret = base.OnKey(key);
+
+ if (selectedAgain == true)
+ {
+ IsSelected = true;
+ selectedAgain = false;
+ }
+
+ return ret;
+ }
+
+ /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override void OnSelected()
+ protected override bool HandleControlStateOnTouch(Touch touch)
{
- if (!IsSelected)
+ if ((IsEnabled == false) || (touch == null))
+ {
+ return false;
+ }
+
+ PointStateType state = touch.GetState(0);
+ switch (state)
+ {
+ case PointStateType.Up:
+ if (IsSelected == true)
+ {
+ selectedAgain = true;
+ }
+ break;
+ default:
+ break;
+ }
+
+ bool ret = base.HandleControlStateOnTouch(touch);
+
+ if (selectedAgain == true)
{
IsSelected = true;
+ selectedAgain = false;
+ }
+
+ return ret;
+ }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void OnControlStateChanged(ControlStateChangedEventArgs info)
+ {
+ if (info.PreviousState.Contains(ControlState.Selected) != info.CurrentState.Contains(ControlState.Selected))
+ {
+ // RadioButton does not invoke SelectedChanged if button or key
+ // is unpressed while its state is selected.
+ if (selectedAgain == true)
+ {
+ return;
+ }
+
+ base.OnControlStateChanged(info);
}
}
}