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 private delegate void KeyInputFocusGainedCallbackDelegate(IntPtr control);
125 private DaliEventHandler<object,KeyInputFocusGainedEventArgs> _KeyInputFocusGainedEventHandler;
126 private KeyInputFocusGainedCallbackDelegate _KeyInputFocusGainedCallbackDelegate;
128 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
129 private delegate void KeyInputFocusLostCallbackDelegate(IntPtr control);
130 private DaliEventHandler<object,KeyInputFocusLostEventArgs> _KeyInputFocusLostEventHandler;
131 private KeyInputFocusLostCallbackDelegate _KeyInputFocusLostCallbackDelegate;
133 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
134 private delegate bool KeyCallbackDelegate(IntPtr control, IntPtr keyEvent);
135 private DaliEventHandlerWithReturnType<object,KeyEventArgs,bool> _KeyEventHandler;
136 private KeyCallbackDelegate _KeyCallbackDelegate;
139 * @brief Event for KeyInputFocusGained signal which can be used to subscribe/unsubscribe the event handler
140 * (in the type of KeyInputFocusGainedEventHandler-DaliEventHandler<object,KeyInputFocusGainedEventArgs>)
141 * provided by the user. KeyInputFocusGained signal is emitted when the control gets Key Input Focus.
143 public event DaliEventHandler<object,KeyInputFocusGainedEventArgs> KeyInputFocusGained
149 // Restricted to only one listener
150 if (_KeyInputFocusGainedEventHandler == null)
152 _KeyInputFocusGainedEventHandler += value;
154 _KeyInputFocusGainedCallbackDelegate = new KeyInputFocusGainedCallbackDelegate(OnKeyInputFocusGained);
155 this.KeyInputFocusGainedSignal().Connect(_KeyInputFocusGainedCallbackDelegate);
164 if (_KeyInputFocusGainedEventHandler != null)
166 this.KeyInputFocusGainedSignal().Disconnect(_KeyInputFocusGainedCallbackDelegate);
169 _KeyInputFocusGainedEventHandler -= value;
174 private void OnKeyInputFocusGained(IntPtr view)
176 KeyInputFocusGainedEventArgs e = new KeyInputFocusGainedEventArgs();
178 // Populate all members of "e" (KeyInputFocusGainedEventArgs) with real data
179 e.View = Dali.View.GetViewFromPtr(view);
181 if (_KeyInputFocusGainedEventHandler != null)
183 //here we send all data to user event handlers
184 _KeyInputFocusGainedEventHandler(this, e);
190 * @brief Event for KeyInputFocusLost signal which can be used to subscribe/unsubscribe the event handler
191 * (in the type of KeyInputFocusLostEventHandler-DaliEventHandler<object,KeyInputFocusLostEventArgs>)
192 * provided by the user. KeyInputFocusLost signal is emitted when the control loses Key Input Focus.
194 public event DaliEventHandler<object,KeyInputFocusLostEventArgs> KeyInputFocusLost
200 // Restricted to only one listener
201 if (_KeyInputFocusLostEventHandler == null)
203 _KeyInputFocusLostEventHandler += value;
205 _KeyInputFocusLostCallbackDelegate = new KeyInputFocusLostCallbackDelegate(OnKeyInputFocusLost);
206 this.KeyInputFocusLostSignal().Connect(_KeyInputFocusLostCallbackDelegate);
215 if (_KeyInputFocusLostEventHandler != null)
217 this.KeyInputFocusLostSignal().Disconnect(_KeyInputFocusLostCallbackDelegate);
220 _KeyInputFocusLostEventHandler -= value;
225 private void OnKeyInputFocusLost(IntPtr view)
227 KeyInputFocusLostEventArgs e = new KeyInputFocusLostEventArgs();
229 // Populate all members of "e" (KeyInputFocusLostEventArgs) with real data
230 e.View = Dali.View.GetViewFromPtr(view);
232 if (_KeyInputFocusLostEventHandler != null)
234 //here we send all data to user event handlers
235 _KeyInputFocusLostEventHandler(this, e);
240 * @brief Event for KeyPressed signal which can be used to subscribe/unsubscribe the event handler
241 * (in the type of KeyEventEventHandler-DaliEventHandlerWithReturnType<object,KeyEventArgs,bool>)
242 * provided by the user. KeyPressed signal is emitted when key event is received.
244 public event DaliEventHandlerWithReturnType<object,KeyEventArgs,bool> KeyPressed
250 // Restricted to only one listener
251 if (_KeyEventHandler == null)
253 _KeyEventHandler += value;
255 _KeyCallbackDelegate = new KeyCallbackDelegate(OnKeyEvent);
256 this.KeyEventSignal().Connect(_KeyCallbackDelegate);
265 if (_KeyEventHandler != null)
267 this.KeyEventSignal().Disconnect(_KeyCallbackDelegate);
270 _KeyEventHandler -= value;
275 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
277 KeyEventArgs e = new KeyEventArgs();
279 // Populate all members of "e" (KeyEventArgs) with real data
280 e.View = Dali.View.GetViewFromPtr(view);
281 e.KeyEvent = Dali.KeyEvent.GetKeyEventFromPtr(keyEvent);
283 if (_KeyEventHandler != null)
285 //here we send all data to user event handlers
286 return _KeyEventHandler(this, e);
292 public static View GetViewFromPtr(global::System.IntPtr cPtr) {
293 View ret = new View(cPtr, false);
294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 %define DALI_CONTROL_EVENTHANDLER_PARAM( NameSpace, ClassName)
304 CONTROL_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
305 CONTROL_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
311 DALI_CONTROL_EVENTHANDLER_PARAM( Dali::Toolkit, Control);