2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
4 using Tizen.NUI.Events;
7 namespace Tizen.NUI.Samples
9 public class TouchGestureSample : IExample
12 private View frontView;
13 private TextLabel backView;
14 private TapGestureDetector tapGestureDetector;
15 private LongPressGestureDetector longPressGestureDetector;
17 public void Activate()
19 Window window = NUIApplication.GetDefaultWindow();
22 window.WheelEvent += (s, e) =>
24 Tizen.Log.Error("NUI", $"window WheelEvent!!!!{e.Wheel.Type}\n");
29 Size = new Size(300, 300),
30 Position = new Position(150, 170),
31 BackgroundColor = new Color(1.0f, 0.0f, 0.0f, 1.0f),
33 FocusableInTouch = true,
35 frontView.TouchEvent += OnFrontTouchEvent;
36 frontView.WheelEvent += (s, e) =>
38 Tizen.Log.Error("NUI", $"frontView WheelEvent!!!!{e.Wheel.Type}\n");
39 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
43 else if (e.Wheel.Type == Wheel.WheelType.MouseWheel)
50 var middleView = new View
52 Size = new Size(300, 300),
53 Position = new Position(110, 120),
54 BackgroundColor = new Color(0.0f, 1.0f, 0.0f, 1.0f),
56 FocusableInTouch = true,
60 // The default the maximum allowed time is 500ms.
61 // If you want to change this time, do as below.
62 // But keep in mind this is a global option. Affects all gestures.
63 GestureOptions.Instance.SetDoubleTapTimeout(300);
64 tapGestureDetector = new TapGestureDetector();
65 tapGestureDetector.Attach(frontView);
66 tapGestureDetector.SetMaximumTapsRequired(2);
67 tapGestureDetector.Detected += (s, e) =>
69 Tizen.Log.Error("NUI", $"OnTap {e.TapGesture.NumberOfTaps}\n");
72 backView = new TextLabel
74 Size = new Size(300, 300),
76 Position = new Position(50, 70),
78 BackgroundColor = new Color(1.0f, 1.0f, 0.0f, 1.0f),
80 FocusableInTouch = true,
82 backView.TouchEvent += OnBackTouchEvent;
83 backView.WheelEvent += (s, e) =>
85 Tizen.Log.Error("NUI", $"backView WheelEvent!!!!{e.Wheel.Type}\n");
89 // The default the minimum holding time is 500ms.
90 // If you want to change this time, do as below.
91 // But keep in mind this is a global option. Affects all gestures.
92 GestureOptions.Instance.SetLongPressMinimumHoldingTime(300);
94 longPressGestureDetector = new LongPressGestureDetector();
95 longPressGestureDetector.Attach(backView);
96 longPressGestureDetector.Detected += (s, e) =>
98 Tizen.Log.Error("NUI", $"OnLongPress\n");
101 backView.Add(middleView);
102 backView.Add(frontView);
107 private bool OnFrontTouchEvent(object source, View.TouchEventArgs e)
109 Tizen.Log.Error("NUI", $"OnFrontTouchEvent {e.Touch.GetState(0)}\n");
114 private bool OnBackTouchEvent(object source, View.TouchEventArgs e)
116 Tizen.Log.Error("NUI", $"OnBackTouchEvent {e.Touch.GetState(0)}\n");
120 public void Deactivate()
124 NUIApplication.GetDefaultWindow().Remove(root);