2 * Copyright (c) 2016 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.
18 %define CONTROL_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
27 %define CONTROL_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
32 * @brief Event arguments that passed via KeyInputFocusGained signal
35 public class KeyInputFocusGainedEventArgs : EventArgs
40 * @brief View - is the view that gets Key Input Focus
57 * @brief Event arguments that passed via KeyInputFocusLost signal
60 public class KeyInputFocusLostEventArgs : EventArgs
65 * @brief View - is the view that loses Key Input Focus
82 * @brief Event arguments that passed via KeyEvent signal
85 public class KeyEventArgs : EventArgs
88 private KeyEvent _keyEvent;
91 * @brief View - is the view that recieves the keyevent.
107 * @brief KeyEvent - is the keyevent sent to the View.
110 public KeyEvent KeyEvent
123 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
124 public delegate void KeyInputFocusGainedEventHandler(object source, KeyInputFocusGainedEventArgs e);
126 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
127 public delegate void KeyInputFocusLostEventHandler(object source, KeyInputFocusLostEventArgs e);
129 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
130 public delegate bool KeyEventHandler(object source, KeyEventArgs e);
132 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
133 private delegate void KeyInputFocusGainedCallbackDelegate(IntPtr view);
134 private KeyInputFocusGainedEventHandler _KeyInputFocusGainedEventHandler;
135 private KeyInputFocusGainedCallbackDelegate _KeyInputFocusGainedCallbackDelegate;
137 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
138 private delegate void KeyInputFocusLostCallbackDelegate(IntPtr view);
139 private KeyInputFocusLostEventHandler _KeyInputFocusLostEventHandler;
140 private KeyInputFocusLostCallbackDelegate _KeyInputFocusLostCallbackDelegate;
142 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
143 private delegate bool KeyCallbackDelegate(IntPtr view, IntPtr keyEvent);
144 private KeyEventHandler _KeyEventHandler;
145 private KeyCallbackDelegate _KeyCallbackDelegate;
148 * @brief Event for KeyInputFocusGained signal which can be used to subscribe/unsubscribe the event handler
149 * (in the type of KeyInputFocusGainedEventHandler) provided by the user.
150 * KeyInputFocusGained signal is emitted when the view gets Key Input Focus.
152 public event KeyInputFocusGainedEventHandler KeyInputFocusGained
158 // Restricted to only one listener
159 if (_KeyInputFocusGainedEventHandler == null)
161 _KeyInputFocusGainedEventHandler += value;
163 _KeyInputFocusGainedCallbackDelegate = new KeyInputFocusGainedCallbackDelegate(OnKeyInputFocusGained);
164 this.KeyInputFocusGainedSignal().Connect(_KeyInputFocusGainedCallbackDelegate);
173 if (_KeyInputFocusGainedEventHandler != null)
175 this.KeyInputFocusGainedSignal().Disconnect(_KeyInputFocusGainedCallbackDelegate);
178 _KeyInputFocusGainedEventHandler -= value;
183 private void OnKeyInputFocusGained(IntPtr view)
185 KeyInputFocusGainedEventArgs e = new KeyInputFocusGainedEventArgs();
187 // Populate all members of "e" (KeyInputFocusGainedEventArgs) with real data
188 e.View = Dali.View.GetViewFromPtr(view);
190 if (_KeyInputFocusGainedEventHandler != null)
192 //here we send all data to user event handlers
193 _KeyInputFocusGainedEventHandler(this, e);
199 * @brief Event for KeyInputFocusLost signal which can be used to subscribe/unsubscribe the event handler
200 * (in the type of KeyInputFocusLostEventHandler) provided by the user.
201 * KeyInputFocusLost signal is emitted when the view loses Key Input Focus.
203 public event KeyInputFocusLostEventHandler KeyInputFocusLost
209 // Restricted to only one listener
210 if (_KeyInputFocusLostEventHandler == null)
212 _KeyInputFocusLostEventHandler += value;
214 _KeyInputFocusLostCallbackDelegate = new KeyInputFocusLostCallbackDelegate(OnKeyInputFocusLost);
215 this.KeyInputFocusLostSignal().Connect(_KeyInputFocusLostCallbackDelegate);
224 if (_KeyInputFocusLostEventHandler != null)
226 this.KeyInputFocusLostSignal().Disconnect(_KeyInputFocusLostCallbackDelegate);
229 _KeyInputFocusLostEventHandler -= value;
234 private void OnKeyInputFocusLost(IntPtr view)
236 KeyInputFocusLostEventArgs e = new KeyInputFocusLostEventArgs();
238 // Populate all members of "e" (KeyInputFocusLostEventArgs) with real data
239 e.View = Dali.View.GetViewFromPtr(view);
241 if (_KeyInputFocusLostEventHandler != null)
243 //here we send all data to user event handlers
244 _KeyInputFocusLostEventHandler(this, e);
249 * @brief Event for KeyPressed signal which can be used to subscribe/unsubscribe the event handler
250 * (in the type of KeyEventEventHandler) provided by the user.
251 * KeyPressed signal is emitted when key event is received.
253 public event KeyEventHandler KeyPressed
259 // Restricted to only one listener
260 if (_KeyEventHandler == null)
262 _KeyEventHandler += value;
264 _KeyCallbackDelegate = new KeyCallbackDelegate(OnKeyEvent);
265 this.KeyEventSignal().Connect(_KeyCallbackDelegate);
274 if (_KeyEventHandler != null)
276 this.KeyEventSignal().Disconnect(_KeyCallbackDelegate);
279 _KeyEventHandler -= value;
284 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
286 KeyEventArgs e = new KeyEventArgs();
288 // Populate all members of "e" (KeyEventArgs) with real data
289 e.View = Dali.View.GetViewFromPtr(view);
290 e.KeyEvent = Dali.KeyEvent.GetKeyEventFromPtr(keyEvent);
292 if (_KeyEventHandler != null)
294 //here we send all data to user event handlers
295 return _KeyEventHandler(this, e);
301 public static View GetViewFromPtr(global::System.IntPtr cPtr) {
302 View ret = new View(cPtr, false);
303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 %define DALI_CONTROL_EVENTHANDLER_PARAM( NameSpace, ClassName)
313 CONTROL_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
314 CONTROL_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
320 DALI_CONTROL_EVENTHANDLER_PARAM( Dali::Toolkit, Control);