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 KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
27 %define KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
31 * @brief Event arguments that passed via FocusChanged signal
34 public class FocusChangedEventArgs : EventArgs
36 private Actor _actorCurrent;
37 private Actor _actorNext;
40 * @brief Actor - is the original focused Actor
43 public Actor ActorCurrent
51 _actorCurrent = value;
56 * @brief Actor - is the current focused Actor
59 public Actor ActorNext
73 * @brief Event arguments that passed via FocusGroupChanged signal
76 public class FocusGroupChangedEventArgs : EventArgs
78 private Actor _currentFocusedActor;
79 private bool _forwardDirection;
82 * @brief Actor - is the current focused Actor
85 public Actor CurrentFocusedActor
89 return _currentFocusedActor;
93 _currentFocusedActor = value;
98 * @brief ForwardDirection - is the direction (forward or backward) in which to move the focus next
101 public bool ForwardDirection
105 return _forwardDirection;
109 _forwardDirection = value;
115 * @brief Event arguments that passed via FocusedActorEnterKey signal
118 public class FocusedActorEnterKeyEventArgs : EventArgs
120 private Actor _actor;
123 * @brief Actor - is the current focused Actor which has the enter key pressed on it.
139 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
140 public delegate void FocusChangedEventHandler(object source, FocusChangedEventArgs e);
142 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
143 public delegate void FocusGroupChangedEventHandler(object source, FocusGroupChangedEventArgs e);
145 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
146 public delegate void FocusedActorEnterKeyEventHandler(object source, FocusedActorEnterKeyEventArgs e);
148 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
149 private delegate void FocusChangedEventCallbackDelegate(IntPtr actorCurrent, IntPtr actorNext);
150 private FocusChangedEventHandler _keyboardFocusManagerFocusChangedEventHandler;
151 private FocusChangedEventCallbackDelegate _keyboardFocusManagerFocusChangedEventCallbackDelegate;
153 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
154 private delegate void FocusGroupChangedEventCallbackDelegate(IntPtr currentFocusedActor, bool forwardDirection);
155 private FocusGroupChangedEventHandler _keyboardFocusManagerFocusGroupChangedEventHandler;
156 private FocusGroupChangedEventCallbackDelegate _keyboardFocusManagerFocusGroupChangedEventCallbackDelegate;
158 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
159 private delegate void FocusedActorEnterKeyEventCallbackDelegate(IntPtr actor);
160 private FocusedActorEnterKeyEventHandler _keyboardFocusManagerFocusedActorEnterKeyEventHandler;
161 private FocusedActorEnterKeyEventCallbackDelegate _keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate;
164 * @brief Event for FocusChanged signal which can be used to subscribe/unsubscribe the event handler
165 * (in the type of FocusChangedEventHandler) provided by the user.
166 * FocusChanged signal is emitted after the current focused actor has been changed.
168 public event FocusChangedEventHandler FocusChanged
174 // Restricted to only one listener
175 if (_keyboardFocusManagerFocusChangedEventHandler == null)
177 _keyboardFocusManagerFocusChangedEventHandler += value;
179 _keyboardFocusManagerFocusChangedEventCallbackDelegate = new FocusChangedEventCallbackDelegate(OnFocusChanged);
180 this.FocusChangedSignal().Connect(_keyboardFocusManagerFocusChangedEventCallbackDelegate);
189 if (_keyboardFocusManagerFocusChangedEventHandler != null)
191 this.FocusChangedSignal().Disconnect(_keyboardFocusManagerFocusChangedEventCallbackDelegate);
194 _keyboardFocusManagerFocusChangedEventHandler -= value;
199 // Callback for KeyboardFocusManager FocusChangedSignal
200 private void OnFocusChanged(IntPtr actorCurrent, IntPtr actorNext)
202 FocusChangedEventArgs e = new FocusChangedEventArgs();
204 // Populate all members of "e" (FocusChangedEventArgs) with real data
205 e.ActorCurrent = Actor.GetActorFromPtr(actorCurrent);
206 e.ActorNext = Actor.GetActorFromPtr(actorNext);
208 if (_keyboardFocusManagerFocusChangedEventHandler != null)
210 //here we send all data to user event handlers
211 _keyboardFocusManagerFocusChangedEventHandler(this, e);
216 * @brief Event for FocusGroupChanged signal which can be used to subscribe/unsubscribe the event handler
217 * (in the type of FocusGroupChangedEventHandler) provided by the user.
218 * FocusGroupChanged signal is emitted when the focus group has been changed.
220 public event FocusGroupChangedEventHandler FocusGroupChanged
226 // Restricted to only one listener
227 if (_keyboardFocusManagerFocusGroupChangedEventHandler == null)
229 _keyboardFocusManagerFocusGroupChangedEventHandler += value;
231 _keyboardFocusManagerFocusGroupChangedEventCallbackDelegate = new FocusGroupChangedEventCallbackDelegate(OnFocusGroupChanged);
232 this.FocusGroupChangedSignal().Connect(_keyboardFocusManagerFocusGroupChangedEventCallbackDelegate);
241 if (_keyboardFocusManagerFocusGroupChangedEventHandler != null)
243 this.FocusGroupChangedSignal().Disconnect(_keyboardFocusManagerFocusGroupChangedEventCallbackDelegate);
246 _keyboardFocusManagerFocusGroupChangedEventHandler -= value;
251 // Callback for KeyboardFocusManager FocusGroupChangedSignal
252 private void OnFocusGroupChanged(IntPtr currentFocusedActor, bool forwardDirection)
254 FocusGroupChangedEventArgs e = new FocusGroupChangedEventArgs();
256 // Populate all members of "e" (FocusGroupChangedEventArgs) with real data
257 e.CurrentFocusedActor = Actor.GetActorFromPtr(currentFocusedActor);
258 e.ForwardDirection = forwardDirection;
260 if (_keyboardFocusManagerFocusGroupChangedEventHandler != null)
262 //here we send all data to user event handlers
263 _keyboardFocusManagerFocusGroupChangedEventHandler(this, e);
268 * @brief Event for FocusedActorEnterKeyPressed signal which can be used to subscribe/unsubscribe the event handler
269 * (in the type of FocusedActorEnterKeyEventHandler) provided by the user.
270 * FocusedActorEnterKeyPressed signal is emitted when the current focused actor has the enter key pressed on it.
272 public event FocusedActorEnterKeyEventHandler FocusedActorEnterKeyPressed
278 // Restricted to only one listener
279 if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler == null)
281 _keyboardFocusManagerFocusedActorEnterKeyEventHandler += value;
283 _keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate = new FocusedActorEnterKeyEventCallbackDelegate(OnFocusedActorEnterKey);
284 this.FocusedActorEnterKeySignal().Connect(_keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate);
293 if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler != null)
295 this.FocusedActorEnterKeySignal().Disconnect(_keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate);
298 _keyboardFocusManagerFocusedActorEnterKeyEventHandler -= value;
303 // Callback for KeyboardFocusManager FocusedActorEnterKeySignal
304 private void OnFocusedActorEnterKey(IntPtr actor)
306 FocusedActorEnterKeyEventArgs e = new FocusedActorEnterKeyEventArgs();
308 // Populate all members of "e" (FocusedActorEnterKeyEventArgs) with real data
309 e.Actor = Actor.GetActorFromPtr(actor);
311 if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler != null)
313 //here we send all data to user event handlers
314 _keyboardFocusManagerFocusedActorEnterKeyEventHandler(this, e);
321 %define DALI_KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_PARAM( NameSpace, ClassName)
322 KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
323 KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
328 DALI_KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_PARAM( Dali::Toolkit, KeyboardFocusManager);