2 * Copyright(c) 2023 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.
21 using Tizen.NUI.BaseComponents;
22 using Tizen.NUI.WindowSystem;
23 using System.Collections.Generic;
25 namespace Tizen.NUI.WindowSystem
27 class Program : NUIApplication
29 protected override void OnCreate()
37 Window win = Window.Instance;
38 inputGen = new InputGenerator(InputGenerator.DeviceType.All, null);
40 win.WindowSize = new Size2D(500, 500);
41 win.KeyEvent += OnKeyEvent;
42 win.BackgroundColor = Color.White;
44 View windowView = new View();
45 windowView.Size2D = new Size2D(500, 500);
46 windowView.BackgroundColor = Color.White;
47 windowView.TouchEvent += OnTouchEvent;
50 centerLabel = new TextLabel("InputGenerator Sample, Click to generate Return Key.");
51 centerLabel.HorizontalAlignment = HorizontalAlignment.Center;
52 centerLabel.VerticalAlignment = VerticalAlignment.Center;
53 centerLabel.TextColor = Color.Black;
54 centerLabel.PointSize = 12.0f;
55 centerLabel.HeightResizePolicy = ResizePolicyType.FillToParent;
56 centerLabel.WidthResizePolicy = ResizePolicyType.FillToParent;
57 windowView.Add(centerLabel);
62 private void OnKeyEvent(object sender, Window.KeyEventArgs e)
64 if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
68 if (e.Key.State == Key.StateType.Down && e.Key.KeyPressedName == "Return")
71 centerLabel.Text = "Return Key Pressed, counter: " + repeatCounter.ToString();
75 private bool OnTouchEvent(object sender, View.TouchEventArgs e)
77 if (e.Touch.GetState(0) == PointStateType.Down)
79 inputGen.GenerateKey("Return", 1);
80 inputGen.GenerateKey("Return", 0);
88 static void Main(string[] args)
90 var app = new Program();
94 private InputGenerator inputGen;
95 private TextLabel centerLabel;
96 int repeatCounter = 0;