3 using Tizen.NUI.BaseComponents;
4 using Tizen.NUI.WindowSystem;
8 * After the app is launched, it is hidden and the focus is skipped.
9 * This is a sample app that becomes SecondarySelection and catches the Copy event of another process.
10 * If there is another SecondarySelection already running on the device, this sample will not work properly.
13 namespace NUIClipboardDataSelected
15 class Program : NUIApplication
17 const string TAG = "clipboard";
19 protected override void OnCreate()
27 Window.Instance.WindowSize = new Size(1, 1);
28 Window.Instance.BackgroundColor = Color.White;
31 Tizen.NUI.WindowSystem.Shell.TizenShell tzShell;
32 tzShell = new Tizen.NUI.WindowSystem.Shell.TizenShell();
33 Window.Instance.SetAcceptFocus(false);
35 Tizen.NUI.WindowSystem.Shell.KVMService kvmService;
36 // window that will act as KVM Service.
37 kvmService = new Tizen.NUI.WindowSystem.Shell.KVMService(tzShell, Window.Instance);
38 kvmService.SetSecondarySelction();
40 // Add a dummy view for easy debugging.
41 View view = NewView();
42 Window.Instance.GetDefaultLayer().Add(view);
44 // Register event handler.
45 Clipboard.Instance.DataSelected += OnClipboardDataSelected;
48 // When copy occurs somewhere, this callback is invoked.
49 public void OnClipboardDataSelected(object sender, ClipboardDataSelectedEventArgs e)
51 // e.MimeType is the MIME type of the copy data that invoked this callback.
52 string selectedType = e.MimeType;
53 Tizen.Log.Info(TAG, $"OnClipboardDataSelected type:{selectedType}\n");
56 // For example, MC app can call Clipboard's GetData() with the MIME type of the event argument.
57 Clipboard.Instance.GetData(selectedType, OnClipboardDataReceived);
60 // When call Clipboard's GetData(), the user callback is called.
61 public void OnClipboardDataReceived(bool success, ClipEvent clipEvent)
65 Tizen.Log.Error(TAG, $"Data receive fail");
69 Tizen.Log.Info(TAG, $"OnClipboardDataReceived type:{clipEvent.MimeType}, data:{clipEvent.Data}\n");
76 Layout = new LinearLayout()
78 LinearOrientation = LinearLayout.Orientation.Vertical,
79 LinearAlignment = LinearLayout.Alignment.Begin,
81 WidthSpecification = LayoutParamPolicies.MatchParent,
82 HeightSpecification = LayoutParamPolicies.WrapContent,
83 BackgroundColor = Color.White,
88 static void Main(string[] args)
90 var app = new Program();