[NUI] Interops for accessibility (#2277)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Button.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System;
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Binding;
21 using Tizen.NUI.Components.Extension;
22 using Tizen.NUI.Accessibility;
23
24 namespace Tizen.NUI.Components
25 {
26     /// <summary>
27     /// ClickedEventArgs is a class to record button click event arguments which will sent to user.
28     /// </summary>
29     /// <since_tizen> 8 </since_tizen>
30     public class ClickedEventArgs : EventArgs
31     {
32     }
33
34     /// <summary>
35     /// SelectedChangedEventArgs is a class to record item selected arguments which will sent to user.
36     /// </summary>
37     /// <since_tizen> 8 </since_tizen>
38     public class SelectedChangedEventArgs : EventArgs
39     {
40         /// <summary> Selected state </summary>
41         /// <since_tizen> 8 </since_tizen>
42         public bool IsSelected { get; set; }
43     }
44
45     /// <summary>
46     /// Button is one kind of common component, a button clearly describes what action will occur when the user selects it.
47     /// Button may contain text or an icon.
48     /// </summary>
49     /// <since_tizen> 6 </since_tizen>
50     public partial class Button : Control
51     {
52         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
53         [EditorBrowsable(EditorBrowsableState.Never)]
54         public static readonly BindableProperty IconRelativeOrientationProperty = BindableProperty.Create(nameof(IconRelativeOrientation), typeof(IconOrientation?), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
55         {
56             var instance = (Button)bindable;
57             var newIconOrientation = (IconOrientation?)newValue;
58             if (instance.iconRelativeOrientation != newIconOrientation)
59             {
60                 instance.iconRelativeOrientation = newIconOrientation;
61                 instance.UpdateUIContent();
62             }
63         },
64         defaultValueCreator: (bindable) => ((Button)bindable).iconRelativeOrientation
65         );
66
67         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
68         [EditorBrowsable(EditorBrowsableState.Never)]
69         public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
70         {
71             var instance = (Button)bindable;
72             if (newValue != null)
73             {
74                 bool newEnabled = (bool)newValue;
75                 if (instance.isEnabled != newEnabled)
76                 {
77                     instance.isEnabled = newEnabled;
78
79                     if (instance.buttonStyle != null)
80                     {
81                         instance.buttonStyle.IsEnabled = newEnabled;
82                     }
83
84                     instance.UpdateState();
85                 }
86             }
87         },
88         defaultValueCreator: (bindable) => ((Button)bindable).isEnabled);
89         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
90         [EditorBrowsable(EditorBrowsableState.Never)]
91         public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
92         {
93             var instance = (Button)bindable;
94             if (newValue != null)
95             {
96                 bool newSelected = (bool)newValue;
97                 if (instance.isSelected != newSelected)
98                 {
99                     instance.isSelected = newSelected;
100
101                     if (instance.buttonStyle != null)
102                     {
103                         instance.buttonStyle.IsSelected = newSelected;
104                     }
105
106                     if (instance.isSelectable)
107                     {
108                         instance.UpdateState();
109                     }
110                 }
111             }
112         },
113         defaultValueCreator: (bindable) =>
114         {
115             var instance = (Button)bindable;
116             return instance.isSelectable && instance.isSelected;
117         });
118         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
119         [EditorBrowsable(EditorBrowsableState.Never)]
120         public static readonly BindableProperty IsSelectableProperty = BindableProperty.Create(nameof(IsSelectable), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) =>
121         {
122             var instance = (Button)bindable;
123             if (newValue != null)
124             {
125                 bool newSelectable = (bool)newValue;
126                 if (instance.isSelectable != newSelectable)
127                 {
128                     instance.isSelectable = newSelectable;
129
130                     if (instance.buttonStyle != null)
131                     {
132                         instance.buttonStyle.IsSelectable = newSelectable;
133                     }
134
135                     instance.UpdateState();
136                 }
137             }
138         },
139         defaultValueCreator: (bindable) => ((Button)bindable).isSelectable);
140
141         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
142         [EditorBrowsable(EditorBrowsableState.Never)]
143         public static readonly BindableProperty IconPaddingProperty = BindableProperty.Create(nameof(IconPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
144         {
145             var instance = (Button)bindable;
146             instance.iconPadding = (Extents)((Extents)newValue).Clone();
147             instance.UpdateUIContent();
148         },
149         defaultValueCreator: (bindable) => ((Button)bindable).iconPadding);
150
151         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
152         [EditorBrowsable(EditorBrowsableState.Never)]
153         public static readonly BindableProperty TextPaddingProperty = BindableProperty.Create(nameof(TextPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) =>
154         {
155             var instance = (Button)bindable;
156             instance.textPadding = (Extents)((Extents)newValue).Clone();
157             instance.UpdateUIContent();
158         },
159         defaultValueCreator: (bindable) => ((Button)bindable).textPadding);
160
161         private IconOrientation? iconRelativeOrientation;
162         private bool isSelected = false;
163         private bool isSelectable = false;
164         private bool isEnabled = true;
165         private Extents iconPadding;
166         private Extents textPadding;
167
168         static Button() { }
169
170         /// <summary>
171         /// Creates a new instance of a Button.
172         /// </summary>
173         /// <since_tizen> 6 </since_tizen>
174         public Button() : base()
175         {
176             Initialize();
177         }
178
179         /// <summary>
180         /// Creates a new instance of a Button with style.
181         /// </summary>
182         /// <param name="style">Create Button by special style defined in UX.</param>
183         /// <since_tizen> 8 </since_tizen>
184         public Button(string style) : base(style)
185         {
186             Initialize();
187         }
188
189         /// <summary>
190         /// Creates a new instance of a Button with style.
191         /// </summary>
192         /// <param name="buttonStyle">Create Button by style customized by user.</param>
193         /// <since_tizen> 8 </since_tizen>
194         public Button(ButtonStyle buttonStyle) : base(buttonStyle)
195         {
196             Initialize();
197         }
198
199         /// <summary>
200         /// Calculates current states for the button<br />
201         /// </summary>
202         [EditorBrowsable(EditorBrowsableState.Never)]
203         protected override AccessibilityStates AccessibilityCalculateStates()
204         {
205             var states = base.AccessibilityCalculateStates();
206             states.Set(AccessibilityState.Enabled, this.IsEnabled);
207             return states;
208         }
209
210         /// <summary>
211         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
212         /// </summary>
213         /// <since_tizen> 6 </since_tizen>
214         [Obsolete("Deprecated in API8; Will be removed in API10. Please use Clicked event instead.")]
215         public event EventHandler<ClickEventArgs> ClickEvent;
216
217         /// <summary>
218         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.
219         /// </summary>
220         /// <since_tizen> 8 </since_tizen>
221         public event EventHandler<ClickedEventArgs> Clicked;
222
223         /// <summary>
224         /// An event for the button state changed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
225         /// </summary>
226         /// <since_tizen> 6 </since_tizen>
227         [Obsolete("Deprecated in API8; Will be removed in API10. Please use View.ControlStateChangedEvent")]
228         public event EventHandler<StateChangedEventArgs> StateChangedEvent
229         {
230             add
231             {
232                 stateChangeHandler += value;
233             }
234             remove
235             {
236                 stateChangeHandler -= value;
237             }
238         }
239
240         /// <summary>
241         /// Icon orientation.
242         /// </summary>
243         /// <since_tizen> 6 </since_tizen>
244         public enum IconOrientation
245         {
246             /// <summary>
247             /// Top.
248             /// </summary>
249             /// <since_tizen> 6 </since_tizen>
250             Top,
251             /// <summary>
252             /// Bottom.
253             /// </summary>
254             /// <since_tizen> 6 </since_tizen>
255             Bottom,
256             /// <summary>
257             /// Left.
258             /// </summary>
259             /// <since_tizen> 6 </since_tizen>
260             Left,
261             /// <summary>
262             /// Right.
263             /// </summary>
264             /// <since_tizen> 6 </since_tizen>
265             Right,
266         }
267
268         /// <summary>
269         /// Button's icon part.
270         /// </summary>
271         /// <since_tizen> 8 </since_tizen>
272         public ImageView Icon
273         {
274             get
275             {
276                 if (null == buttonIcon)
277                 {
278                     buttonIcon = CreateIcon();
279                     if (null != Extension)
280                     {
281                         buttonIcon = Extension.OnCreateIcon(this, buttonIcon);
282                     }
283                     if (null != buttonIcon)
284                     {
285                         Add(buttonIcon);
286                         buttonIcon.Relayout += OnIconRelayout;
287                     }
288                 }
289                 return buttonIcon;
290             }
291             internal set
292             {
293                 buttonIcon = value;
294             }
295         }
296
297         /// <summary>
298         /// Button's overlay image part.
299         /// </summary>
300         /// <since_tizen> 8 </since_tizen>
301         public ImageView OverlayImage
302         {
303             get
304             {
305                 if (null == overlayImage)
306                 {
307                     overlayImage = CreateOverlayImage();
308                     if (null != Extension)
309                     {
310                         overlayImage = Extension.OnCreateOverlayImage(this, overlayImage);
311                     }
312                     if (null != overlayImage)
313                     {
314                         Add(overlayImage);
315                     }
316                 }
317                 return overlayImage;
318             }
319             internal set
320             {
321                 overlayImage = value;
322             }
323         }
324
325         /// <summary>
326         /// Button's text part.
327         /// </summary>
328         /// <since_tizen> 8 </since_tizen>
329         public TextLabel TextLabel
330         {
331             get
332             {
333                 if (null == buttonText)
334                 {
335                     buttonText = CreateText();
336                     if (null != Extension)
337                     {
338                         buttonText = Extension.OnCreateText(this, buttonText);
339                     }
340                     if (null != buttonText)
341                     {
342                         Add(buttonText);
343                     }
344                 }
345                 return buttonText;
346             }
347             internal set
348             {
349                 buttonText = value;
350                 AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Label, buttonText.Text);
351             }
352         }
353
354         /// <summary>
355         /// Return a copied Style instance of Button
356         /// </summary>
357         /// <remarks>
358         /// It returns copied Style instance and changing it does not effect to the Button.
359         /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
360         /// </remarks>
361         /// <since_tizen> 8 </since_tizen>
362         public new ButtonStyle Style
363         {
364             get
365             {
366                 var result = (ButtonStyle)ViewStyle.Clone();
367                 result.CopyPropertiesFromView(this);
368                 result.Text.CopyPropertiesFromView(TextLabel);
369                 result.Icon.CopyPropertiesFromView(Icon);
370                 result.Overlay.CopyPropertiesFromView(OverlayImage);
371                 return result;
372             }
373         }
374
375         /// <summary>
376         /// The text of Button.
377         /// </summary>
378         /// <since_tizen> 6 </since_tizen>
379         public string Text
380         {
381             get
382             {
383                 return TextLabel.Text;
384             }
385             set
386             {
387                 TextLabel.Text = value;
388
389                 if (IsHighlighted && String.IsNullOrEmpty(AccessibilityName) && GetNameSignal().Empty())
390                 {
391                     EmitAccessibilityEvent(ObjectPropertyChangeEvent.Name);
392                 }
393             }
394         }
395
396         /// <summary>
397         /// Flag to decide Button can be selected or not.
398         /// </summary>
399         /// <since_tizen> 6 </since_tizen>
400         public bool IsSelectable
401         {
402             get
403             {
404                 return (bool)GetValue(IsSelectableProperty);
405             }
406             set
407             {
408                 SetValue(IsSelectableProperty, value);
409             }
410         }
411
412         /// <summary>
413         /// Translate text string in Button.
414         /// </summary>
415         /// <since_tizen> 6 </since_tizen>
416         public string TranslatableText
417         {
418             get
419             {
420                 return TextLabel.TranslatableText;
421             }
422             set
423             {
424                 TextLabel.TranslatableText = value;
425             }
426         }
427
428         /// <summary>
429         /// Text point size in Button.
430         /// </summary>
431         /// <since_tizen> 6 </since_tizen>
432         public float PointSize
433         {
434             get
435             {
436                 return TextLabel.PointSize;
437             }
438             set
439             {
440                 TextLabel.PointSize = value;
441             }
442         }
443
444         /// <summary>
445         /// Text font family in Button.
446         /// </summary>
447         /// <since_tizen> 6 </since_tizen>
448         public string FontFamily
449         {
450             get
451             {
452                 return TextLabel.FontFamily;
453             }
454             set
455             {
456                 TextLabel.FontFamily = value;
457             }
458         }
459
460         /// <summary>
461         /// Text color in Button.
462         /// </summary>
463         /// <since_tizen> 6 </since_tizen>
464         public Color TextColor
465         {
466             get
467             {
468                 return TextLabel.TextColor;
469             }
470             set
471             {
472                 TextLabel.TextColor = value;
473             }
474         }
475
476         /// <summary>
477         /// Text horizontal alignment in Button.
478         /// </summary>
479         /// <since_tizen> 6 </since_tizen>
480         public HorizontalAlignment TextAlignment
481         {
482             get
483             {
484                 return TextLabel.HorizontalAlignment;
485             }
486             set
487             {
488                 TextLabel.HorizontalAlignment = value;
489             }
490         }
491
492         /// <summary>
493         /// Icon image's resource url in Button.
494         /// </summary>
495         /// <since_tizen> 6 </since_tizen>
496         public string IconURL
497         {
498             get
499             {
500                 return Icon.ResourceUrl;
501             }
502             set
503             {
504                 Icon.ResourceUrl = value;
505             }
506         }
507
508         /// <summary>
509         /// Text string selector in Button.
510         /// Getter returns copied selector value if exist, null otherwise.
511         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
512         /// </summary>
513         /// <since_tizen> 6 </since_tizen>
514         public StringSelector TextSelector
515         {
516             get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TextSelectorProperty));
517             set
518             {
519                 if (value == null || buttonText == null)
520                 {
521                     throw new NullReferenceException("Button.TextSelector is null");
522                 }
523                 else
524                 {
525                     buttonText.SetValue(TextLabel.TextSelectorProperty, value);
526                 }
527             }
528         }
529
530         /// <summary>
531         /// Translateable text string selector in Button.
532         /// Getter returns copied selector value if exist, null otherwise.
533         /// </summary>
534         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
535         /// <since_tizen> 6 </since_tizen>
536         public StringSelector TranslatableTextSelector
537         {
538             get => buttonText == null ? null : new StringSelector((Selector<string>)buttonText.GetValue(TextLabel.TranslatableTextSelectorProperty));
539             set
540             {
541                 if (value == null || buttonText == null)
542                 {
543                     throw new NullReferenceException("Button.TranslatableTextSelector is null");
544                 }
545                 else
546                 {
547                     buttonText.SetValue(TextLabel.TranslatableTextSelectorProperty, value);
548                 }
549             }
550         }
551
552         /// <summary>
553         /// Text color selector in Button.
554         /// Getter returns copied selector value if exist, null otherwise.
555         /// </summary>
556         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
557         /// <since_tizen> 6 </since_tizen>
558         public ColorSelector TextColorSelector
559         {
560             get => buttonText == null ? null : new ColorSelector((Selector<Color>)buttonText.GetValue(TextLabel.TextColorSelectorProperty));
561             set
562             {
563                 if (value == null || buttonText == null)
564                 {
565                     throw new NullReferenceException("Button.TextColorSelectorProperty is null");
566                 }
567                 else
568                 {
569                     buttonText.SetValue(TextLabel.TextColorSelectorProperty, value);
570                 }
571             }
572         }
573
574         /// <summary>
575         /// Text font size selector in Button.
576         /// Getter returns copied selector value if exist, null otherwise.
577         /// </summary>
578         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
579         /// <since_tizen> 6 </since_tizen>
580         public FloatSelector PointSizeSelector
581         {
582             get => buttonText == null ? null : new FloatSelector((Selector<float?>)buttonText.GetValue(TextLabel.PointSizeSelectorProperty));
583             set
584             {
585                 if (value == null || buttonText == null)
586                 {
587                     throw new NullReferenceException("Button.PointSizeSelector is null");
588                 }
589                 else
590                 {
591                     buttonText.SetValue(TextLabel.PointSizeSelectorProperty, value);
592                 }
593             }
594         }
595
596         /// <summary>
597         /// Icon image's resource url selector in Button.
598         /// Getter returns copied selector value if exist, null otherwise.
599         /// </summary>
600         /// <exception cref="NullReferenceException">Thrown when setting null value.</exception>
601         /// <since_tizen> 6 </since_tizen>
602         public StringSelector IconURLSelector
603         {
604             get => buttonIcon == null ? null : new StringSelector((Selector<string>)buttonIcon.GetValue(ImageView.ResourceUrlSelectorProperty));
605             set
606             {
607                 if (value == null || buttonIcon == null)
608                 {
609                     throw new NullReferenceException("Button.IconURLSelector is null");
610                 }
611                 else
612                 {
613                     buttonIcon.SetValue(ImageView.ResourceUrlSelectorProperty, value);
614                 }
615             }
616         }
617
618         /// <summary>
619         /// Flag to decide selected state in Button.
620         /// </summary>
621         /// <since_tizen> 6 </since_tizen>
622         public bool IsSelected
623         {
624             get
625             {
626                 return (bool)GetValue(IsSelectedProperty);
627             }
628             set
629             {
630                 SetValue(IsSelectedProperty, value);
631             }
632         }
633
634         /// <summary>
635         /// Flag to decide enable or disable in Button.
636         /// </summary>
637         /// <since_tizen> 6 </since_tizen>
638         public bool IsEnabled
639         {
640             get
641             {
642                 return (bool)GetValue(IsEnabledProperty);
643             }
644             set
645             {
646                 SetValue(IsEnabledProperty, value);
647             }
648         }
649
650         /// <summary>
651         /// Icon relative orientation in Button, work only when show icon and text.
652         /// </summary>
653         /// <since_tizen> 8 </since_tizen>
654         public IconOrientation? IconRelativeOrientation
655         {
656             get
657             {
658                 return (IconOrientation?)GetValue(IconRelativeOrientationProperty) ?? IconOrientation.Left;
659             }
660             set
661             {
662                 SetValue(IconRelativeOrientationProperty, value);
663             }
664         }
665
666         /// <summary>
667         /// Icon padding in Button, work only when show icon and text.
668         /// </summary>
669         /// <since_tizen> 6 </since_tizen>
670         public Extents IconPadding
671         {
672             get => (Extents)GetValue(IconPaddingProperty) ?? new Extents();
673             set => SetValue(IconPaddingProperty, value);
674         }
675
676         /// <summary>
677         /// Text padding in Button, work only when show icon and text.
678         /// </summary>
679         /// <since_tizen> 6 </since_tizen>
680         public Extents TextPadding
681         {
682             get => (Extents)GetValue(TextPaddingProperty) ?? new Extents();
683             set => SetValue(TextPaddingProperty, value);
684         }
685
686         private ButtonStyle buttonStyle => ViewStyle as ButtonStyle;
687
688         /// <summary>
689         /// Called after a key event is received by the view that has had its focus set.
690         /// </summary>
691         /// <param name="key">The key event.</param>
692         /// <returns>True if the key event should be consumed.</returns>
693         /// <since_tizen> 6 </since_tizen>
694         public override bool OnKey(Key key)
695         {
696             if (!IsEnabled || null == key)
697             {
698                 return false;
699             }
700
701             if (key.State == Key.StateType.Down)
702             {
703                 if (key.KeyPressedName == "Return")
704                 {
705                     isPressed = true;
706                     UpdateState();
707                 }
708             }
709             else if (key.State == Key.StateType.Up)
710             {
711                 if (key.KeyPressedName == "Return")
712                 {
713                     bool clicked = isPressed && IsEnabled;
714
715                     isPressed = false;
716
717                     if (IsSelectable)
718                     {
719                         IsSelected = !IsSelected;
720                     }
721                     else
722                     {
723                         UpdateState();
724                     }
725
726                     if (clicked)
727                     {
728                         ClickedEventArgs eventArgs = new ClickedEventArgs();
729                         OnClickedInternal(eventArgs);
730                     }
731                 }
732             }
733             return base.OnKey(key);
734         }
735
736         /// <summary>
737         /// Called when the control gain key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is gained.
738         /// </summary>
739         /// <since_tizen> 8 </since_tizen>
740         public override void OnFocusGained()
741         {
742             base.OnFocusGained();
743             UpdateState();
744         }
745
746         /// <summary>
747         /// Called when the control loses key input focus. Should be overridden by derived classes if they need to customize what happens when the focus is lost.
748         /// </summary>
749         /// <since_tizen> 8 </since_tizen>
750         public override void OnFocusLost()
751         {
752             base.OnFocusLost();
753             UpdateState();
754         }
755
756         /// <summary>
757         /// Called after a touch event is received by the owning view.<br />
758         /// CustomViewBehaviour.REQUIRES_TOUCH_EVENTS must be enabled during construction. See CustomView(ViewWrapperImpl.CustomViewBehaviour behaviour).<br />
759         /// </summary>
760         /// <param name="touch">The touch event.</param>
761         /// <returns>True if the event should be consumed.</returns>
762         /// <since_tizen> 8 </since_tizen>
763         [Obsolete("Deprecated in API8; Will be removed in API10. Please use OnClicked instead.")]
764 #pragma warning disable CS0809 // Obsolete member overrides non-obsolete member, It will be removed in API10
765         public override bool OnTouch(Touch touch)
766 #pragma warning restore CS0809 // Obsolete member overrides non-obsolete member, It will be removed in API10
767         {
768             return base.OnTouch(touch);
769         }
770
771         /// <summary>
772         /// Apply style to button.
773         /// </summary>
774         /// <param name="viewStyle">The style to apply.</param>
775         /// <since_tizen> 8 </since_tizen>
776         public override void ApplyStyle(ViewStyle viewStyle)
777         {
778             styleApplied = false;
779
780             base.ApplyStyle(viewStyle);
781
782             if (null != buttonStyle)
783             {
784                 Extension = buttonStyle.CreateExtension();
785                 if (buttonStyle.Overlay != null)
786                 {
787                     OverlayImage?.ApplyStyle(buttonStyle.Overlay);
788                 }
789
790                 if (buttonStyle.Text != null)
791                 {
792                     TextLabel?.ApplyStyle(buttonStyle.Text);
793                 }
794
795                 if (buttonStyle.Icon != null)
796                 {
797                     Icon?.ApplyStyle(buttonStyle.Icon);
798                 }
799             }
800
801             styleApplied = true;
802         }
803
804         /// <summary>
805         /// ClickEventArgs is a class to record button click event arguments which will sent to user.
806         /// </summary>
807         /// <since_tizen> 6 </since_tizen>
808         [Obsolete("Deprecated in API8; Will be removed in API10. Please use ClickedEventArgs instead.")]
809         [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
810         public class ClickEventArgs : EventArgs
811         {
812         }
813
814         /// <summary>
815         /// StateChangeEventArgs is a class to record button state change event arguments which will sent to user.
816         /// </summary>
817         /// <since_tizen> 6 </since_tizen>
818         [Obsolete("Deprecated in API8; Will be removed in API10. Please use View.ControlStateChangedEventArgs")]
819         [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
820         public class StateChangedEventArgs : EventArgs
821         {
822             /// <summary> previous state of Button </summary>
823             /// <since_tizen> 6 </since_tizen>
824             /// It will be removed in API10
825             [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
826             [Obsolete("Deprecated in API8; Will be removed in API10")]
827             public ControlStates PreviousState;
828             /// <summary> current state of Button </summary>
829             /// <since_tizen> 6 </since_tizen>
830             /// It will be removed in API10
831             [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
832             [Obsolete("Deprecated in API8; Will be removed in API10")]
833             public ControlStates CurrentState;
834         }
835     }
836 }