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 TEXTEDITOR_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
27 %define TEXTEDITOR_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
31 * @brief Event arguments that passed via TextChanged signal
34 public class TextChangedEventArgs : EventArgs
36 private TextEditor _textEditor;
38 * @brief TextEditor - is the texteditor control which has the text contents changed.
41 public TextEditor TextEditor
53 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
54 public delegate void TextChangedEventHandler(object source, TextChangedEventArgs e);
56 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
57 private delegate void TextChangedCallbackDelegate(IntPtr textEditor);
58 private TextChangedEventHandler _textEditorTextChangedEventHandler;
59 private TextChangedCallbackDelegate _textEditorTextChangedCallbackDelegate;
62 * @brief Event for TextChanged signal which can be used to subscribe/unsubscribe the event handler
63 * (in the type of TextChangedEventHandler) provided by the user.
64 * TextChanged signal is emitted when the text changes.
66 public event TextChangedEventHandler TextChanged
72 // Restricted to only one listener
73 if (_textEditorTextChangedEventHandler == null)
75 _textEditorTextChangedEventHandler += value;
77 _textEditorTextChangedCallbackDelegate = new TextChangedCallbackDelegate(OnTextChanged);
78 this.TextChangedSignal().Connect(_textEditorTextChangedCallbackDelegate);
87 if (_textEditorTextChangedEventHandler != null)
89 this.TextChangedSignal().Disconnect(_textEditorTextChangedCallbackDelegate);
92 _textEditorTextChangedEventHandler -= value;
97 private void OnTextChanged(IntPtr textEditor)
99 TextChangedEventArgs e = new TextChangedEventArgs();
101 // Populate all members of "e" (TextChangedEventArgs) with real data
102 e.TextEditor = Dali.TextEditor.GetTextEditorFromPtr(textEditor);
104 if (_textEditorTextChangedEventHandler != null)
106 //here we send all data to user event handlers
107 _textEditorTextChangedEventHandler(this, e);
112 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
113 ClassName ret = new ClassName(cPtr, false);
114 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122 %define DALI_TEXTEDITOR_EVENTHANDLER_PARAM( NameSpace, ClassName)
124 TEXTEDITOR_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
125 TEXTEDITOR_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
131 DALI_TEXTEDITOR_EVENTHANDLER_PARAM( Dali::Toolkit, TextEditor);