2 * Copyright(c) 2020 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.
17 using System.ComponentModel;
18 using System.Diagnostics.CodeAnalysis;
19 using Tizen.NUI.BaseComponents;
21 namespace Tizen.NUI.Components
24 /// TabButton is a class which is used for selecting one content in a TabView.
26 [EditorBrowsable(EditorBrowsableState.Never)]
27 public class TabButton : SelectButton
29 private bool selectedAgain = false;
32 /// Creates a new instance of TabButton.
34 [EditorBrowsable(EditorBrowsableState.Never)]
37 GridLayout.SetHorizontalStretch(this, GridLayout.StretchFlags.ExpandAndFill);
41 [EditorBrowsable(EditorBrowsableState.Never)]
42 public override bool OnKey(Key key)
44 if ((IsEnabled == false) || (key == null))
49 if (key.State == Key.StateType.Up)
51 if (key.KeyPressedName == "Return")
53 if (IsSelected == true)
60 bool ret = base.OnKey(key);
62 if (selectedAgain == true)
65 selectedAgain = false;
72 [EditorBrowsable(EditorBrowsableState.Never)]
73 protected override bool HandleControlStateOnTouch(Touch touch)
75 if ((IsEnabled == false) || (touch == null))
80 PointStateType state = touch.GetState(0);
83 case PointStateType.Up:
84 if (IsSelected == true)
93 bool ret = base.HandleControlStateOnTouch(touch);
95 if (selectedAgain == true)
98 selectedAgain = false;
105 [SuppressMessage("Microsoft.Design",
106 "CA1062: Validate arguments of public methods",
107 MessageId = "controlStateChangedInfo",
108 Justification = "OnControlStateChanged is called when controlState is changed so controlStateChangedInfo cannot be null.")]
109 [EditorBrowsable(EditorBrowsableState.Never)]
110 protected override void OnControlStateChanged(ControlStateChangedEventArgs controlStateChangedInfo)
112 if (controlStateChangedInfo.PreviousState.Contains(ControlState.Selected) != controlStateChangedInfo.CurrentState.Contains(ControlState.Selected))
114 // TabButton does not invoke SelectedChanged if button or key is
115 // unpressed while its state is selected.
116 if (selectedAgain == true)
121 base.OnControlStateChanged(controlStateChangedInfo);