2 * Copyright(c) 2021 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.
19 using System.ComponentModel;
20 using System.Runtime.InteropServices;
22 namespace Tizen.NUI.BaseComponents
25 /// A control which renders a short text string.<br />
26 /// Text labels are lightweight, non-editable, and do not respond to the user input.<br />
28 /// <since_tizen> 3 </since_tizen>
29 public partial class TextLabel
31 private EventHandler<AnchorClickedEventArgs> textLabelAnchorClickedEventHandler;
32 private AnchorClickedCallbackDelegate textLabelAnchorClickedCallbackDelegate;
34 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
35 private delegate void AnchorClickedCallbackDelegate(IntPtr textLabel, IntPtr href, uint hrefLength);
38 /// The AnchorClicked signal is emitted when the anchor is clicked.
40 /// <since_tizen> 9 </since_tizen>
41 public event EventHandler<AnchorClickedEventArgs> AnchorClicked
45 if (textLabelAnchorClickedEventHandler == null)
47 textLabelAnchorClickedCallbackDelegate = (OnAnchorClicked);
48 AnchorClickedSignal().Connect(textLabelAnchorClickedCallbackDelegate);
50 textLabelAnchorClickedEventHandler += value;
54 textLabelAnchorClickedEventHandler -= value;
55 if (textLabelAnchorClickedEventHandler == null && AnchorClickedSignal().Empty() == false)
57 AnchorClickedSignal().Disconnect(textLabelAnchorClickedCallbackDelegate);
62 internal TextLabelSignal AnchorClickedSignal()
64 TextLabelSignal ret = new TextLabelSignal(Interop.TextLabel.AnchorClickedSignal(SwigCPtr), false);
65 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
69 private void OnAnchorClicked(IntPtr textLabel, IntPtr href, uint hrefLength)
71 // Note: hrefLength is useful for get the length of a const char* (href) in dali-toolkit.
72 // But NUI can get the length of string (href), so hrefLength is not necessary in NUI.
73 AnchorClickedEventArgs e = new AnchorClickedEventArgs();
75 // Populate all members of "e" (AnchorClickedEventArgs) with real data
76 e.Href = Marshal.PtrToStringAnsi(href);
77 //here we send all data to user event handlers
78 textLabelAnchorClickedEventHandler?.Invoke(this, e);