[NUI] Change all CallingConvention to `Cdecl`
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / TextEditorEvent.cs
index c238807..8a37327 100755 (executable)
@@ -42,33 +42,47 @@ namespace Tizen.NUI.BaseComponents
         private EventHandler<AnchorClickedEventArgs> textEditorAnchorClickedEventHandler;
         private AnchorClickedCallbackDelegate textEditorAnchorClickedCallbackDelegate;
 
+        private EventHandler textEditorSelectionClearedEventHandler;
+        private SelectionClearedCallbackDelegate textEditorSelectionClearedCallbackDelegate;
+
+        private EventHandler textEditorSelectionStartedEventHandler;
+        private SelectionStartedCallbackDelegate textEditorSelectionStartedCallbackDelegate;
+
         private EventHandler textEditorSelectionChangedEventHandler;
         private SelectionChangedCallbackDelegate textEditorSelectionChangedCallbackDelegate;
 
         private EventHandler<InputFilteredEventArgs> textEditorInputFilteredEventHandler;
         private InputFilteredCallbackDelegate textEditorInputFilteredCallbackDelegate;
 
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void TextChangedCallbackDelegate(IntPtr textEditor);
 
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void ScrollStateChangedCallbackDelegate(IntPtr textEditor, ScrollState state);
 
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void CursorPositionChangedCallbackDelegate(IntPtr textEditor, uint oldPosition);
 
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void MaxLengthReachedCallbackDelegate(IntPtr textEditor);
 
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        private delegate void SelectionClearedCallbackDelegate(IntPtr textEditor);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        private delegate void SelectionStartedCallbackDelegate(IntPtr textEditor);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void AnchorClickedCallbackDelegate(IntPtr textEditor, IntPtr href, uint hrefLength);
 
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void SelectionChangedCallbackDelegate(IntPtr textEditor, uint oldStart, uint oldEnd);
 
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         private delegate void InputFilteredCallbackDelegate(IntPtr textEditor, InputFilterType type);
 
+        private bool invokeTextChanged = true;
+
         /// <summary>
         /// An event for the TextChanged signal which can be used to subscribe or unsubscribe the event handler
         /// provided by the user. The TextChanged signal is emitted when the text changes.<br />
@@ -122,10 +136,9 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// The CursorPositionChanged event.
+        /// The CursorPositionChanged event is emitted whenever the primary cursor position changed.
         /// </summary>
-        /// This will be public opened after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
+        /// <since_tizen> 9 </since_tizen>
         public event EventHandler CursorPositionChanged
         {
             add
@@ -199,10 +212,59 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
-        /// The SelectionChanged event.
+        /// The SelectionStarted event is emitted when the selection has been started.
         /// </summary>
-        /// This will be public opened after ACR done. Before ACR, need to be hidden as inhouse API.
-        [EditorBrowsable(EditorBrowsableState.Never)]
+        /// <since_tizen> 10 </since_tizen>
+        public event EventHandler SelectionStarted
+        {
+            add
+            {
+                if (textEditorSelectionStartedEventHandler == null)
+                {
+                    textEditorSelectionStartedCallbackDelegate = (OnSelectionStarted);
+                    SelectionStartedSignal().Connect(textEditorSelectionStartedCallbackDelegate);
+                }
+                textEditorSelectionStartedEventHandler += value;
+            }
+            remove
+            {
+                if (textEditorSelectionStartedEventHandler == null && SelectionStartedSignal().Empty() == false)
+                {
+                    this.SelectionStartedSignal().Disconnect(textEditorSelectionStartedCallbackDelegate);
+                }
+                textEditorSelectionStartedEventHandler -= value;
+            }
+        }
+
+        /// <summary>
+        /// The SelectionCleared signal is emitted when selection is cleared.
+        /// </summary>
+        /// <since_tizen> 9 </since_tizen>
+        public event EventHandler SelectionCleared
+        {
+            add
+            {
+                if (textEditorSelectionClearedEventHandler == null)
+                {
+                    textEditorSelectionClearedCallbackDelegate = (OnSelectionCleared);
+                    SelectionClearedSignal().Connect(textEditorSelectionClearedCallbackDelegate);
+                }
+                textEditorSelectionClearedEventHandler += value;
+            }
+            remove
+            {
+                if (textEditorSelectionClearedEventHandler == null && SelectionClearedSignal().Empty() == false)
+                {
+                    this.SelectionClearedSignal().Disconnect(textEditorSelectionClearedCallbackDelegate);
+                }
+                textEditorSelectionClearedEventHandler -= value;
+            }
+        }
+
+        /// <summary>
+        /// The SelectionChanged event is emitted whenever the selected text is changed.
+        /// </summary>
+        /// <since_tizen> 9 </since_tizen>
         public event EventHandler SelectionChanged
         {
             add
@@ -246,7 +308,7 @@ namespace Tizen.NUI.BaseComponents
         /// };
         /// </code>
         /// </example>
-        [EditorBrowsable(EditorBrowsableState.Never)]
+        /// <since_tizen> 9 </since_tizen>
         public event EventHandler<InputFilteredEventArgs> InputFiltered
         {
             add
@@ -268,6 +330,20 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        internal TextEditorSignal SelectionStartedSignal()
+        {
+            TextEditorSignal ret = new TextEditorSignal(Interop.TextEditor.SelectionStartedSignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        internal TextEditorSignal SelectionClearedSignal()
+        {
+            TextEditorSignal ret = new TextEditorSignal(Interop.TextEditor.SelectionClearedSignal(SwigCPtr), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
         internal TextEditorSignal TextChangedSignal()
         {
             TextEditorSignal ret = new TextEditorSignal(Interop.TextEditor.TextChangedSignal(SwigCPtr), false);
@@ -319,7 +395,7 @@ namespace Tizen.NUI.BaseComponents
 
         private void OnTextChanged(IntPtr textEditor)
         {
-            if (textEditorTextChangedEventHandler != null)
+            if (textEditorTextChangedEventHandler != null && invokeTextChanged)
             {
                 TextChangedEventArgs e = new TextChangedEventArgs();
 
@@ -330,6 +406,18 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        private void OnSelectionStarted(IntPtr textEditor)
+        {
+            //no data to be sent to the user
+            textEditorSelectionStartedEventHandler?.Invoke(this, EventArgs.Empty);
+        }
+
+        private void OnSelectionCleared(IntPtr textEditor)
+        {
+            //no data to be sent to the user
+            textEditorSelectionClearedEventHandler?.Invoke(this, EventArgs.Empty);
+        }
+
         private void OnScrollStateChanged(IntPtr textEditor, ScrollState state)
         {
             if (textEditorScrollStateChangedEventHandler != null)