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