Setting since_tizen 3/4 on Tizen.NET API
[platform/core/csapi/tizenfx.git] / src / Tizen.Uix.InputMethod / Tizen.Uix.InputMethod / InputMethodEditor.cs
1 /*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17
18 using System;
19 using System.Collections.Generic;
20 using System.Runtime.InteropServices;
21 using static Interop.InputMethod;
22
23 namespace Tizen.Uix.InputMethod
24 {
25     /// <summary>
26     /// Enumeration of the key codes.
27     /// If keycode &amp; 0xff000000 == 0x01000000 then this key code is directly encoded 24-bit UCS character.The UCS value is keycode &amp; 0x00ffffff.
28     /// Defines the list of keys supported by the system.Note that certain keys may not be available on all devices.
29     /// </summary>
30     /// <since_tizen> 4 </since_tizen>
31     public enum KeyCode
32     {
33         /// <summary>
34         /// The backspace key
35         /// </summary>
36         BackSpace = 0xFF08,
37         /// <summary>
38         /// The tab key
39         /// </summary>
40         Tab = 0xFF09,
41         /// <summary>
42         /// The linefeed key
43         /// </summary>
44         Linefeed = 0xFF0A,
45         /// <summary>
46         /// The clear key
47         /// </summary>
48         Clear = 0xFF0B,
49         /// <summary>
50         /// The return key
51         /// </summary>
52         Return = 0xFF0D,
53         /// <summary>
54         /// The pause key
55         /// </summary>
56         Pause = 0xFF13,
57         /// <summary>
58         /// The scroll lock key
59         /// </summary>
60         ScrollLock = 0xFF14,
61         /// <summary>
62         /// The sys req key
63         /// </summary>
64         SysReq = 0xFF15,
65         /// <summary>
66         /// The escape key
67         /// </summary>
68         Escape = 0xFF1B,
69         /// <summary>
70         /// The delete key
71         /// </summary>
72         Delete = 0xFFFF,
73
74         /* Cursor control & motion */
75         /// <summary>
76         /// The home key
77         /// </summary>
78         Home = 0xFF50,
79         /// <summary>
80         /// The left directional key
81         /// </summary>
82         Left = 0xFF51,
83         /// <summary>
84         /// The up directional key
85         /// </summary>
86         Up = 0xFF52,
87         /// <summary>
88         /// The right directional key
89         /// </summary>
90         Right = 0xFF53,
91         /// <summary>
92         /// The down directional key
93         /// </summary>
94         Down = 0xFF54,
95         /// <summary>
96         /// The prior, previous key
97         /// </summary>
98         Prior = 0xFF55,
99         /// <summary>
100         /// The page up key
101         /// </summary>
102         Page_Up = 0xFF55,
103         /// <summary>
104         /// The next key
105         /// </summary>
106         Next = 0xFF56,
107         /// <summary>
108         /// The page down key
109         /// </summary>
110         Page_Down = 0xFF56,
111         /// <summary>
112         /// The end key
113         /// </summary>
114         End = 0xFF57,
115         /// <summary>
116         /// The begin key
117         /// </summary>
118         Begin = 0xFF58,
119
120         /* Misc Functions */
121         /// <summary>
122         /// The select key
123         /// </summary>
124         Select = 0xFF60,
125         /// <summary>
126         /// The print key
127         /// </summary>
128         Print = 0xFF61,
129         /// <summary>
130         /// The execute, run, do key
131         /// </summary>
132         Execute = 0xFF62,
133         /// <summary>
134         /// The insert key
135         /// </summary>
136         Insert = 0xFF63,
137         /// <summary>
138         /// The undo key
139         /// </summary>
140         Undo = 0xFF65,
141         /// <summary>
142         /// The redo key
143         /// </summary>
144         Redo = 0xFF66,
145         /// <summary>
146         /// The menu key
147         /// </summary>
148         Menu = 0xFF67,
149         /// <summary>
150         /// The find key
151         /// </summary>
152         Find = 0xFF68,
153         /// <summary>
154         /// The cancel, stop, abort, exit key
155         /// </summary>
156         Cancel = 0xFF69,
157         /// <summary>
158         /// The help key
159         /// </summary>
160         Help = 0xFF6A,
161         /// <summary>
162         /// The break key
163         /// </summary>
164         Break = 0xFF6B,
165         /// <summary>
166         /// The character set switch key
167         /// </summary>
168         Mode_switch = 0xFF7E,
169         /// <summary>
170         /// The num lock key
171         /// </summary>
172         Num_Lock = 0xFF7F,
173
174         /* Keypad */
175         /// <summary>
176         /// The Numpad space key
177         /// </summary>
178         KPSpace = 0xFF80,
179         /// <summary>
180         /// The Numpad tab key
181         /// </summary>
182         KPTab = 0xFF89,
183         /// <summary>
184         /// The Numpad enter key
185         /// </summary>
186         KPEnter = 0xFF8D,
187         /// <summary>
188         /// The Numpad function 1 key
189         /// </summary>
190         KPF1 = 0xFF91,
191         /// <summary>
192         /// The Numpad function 2 key
193         /// </summary>
194         KPF2 = 0xFF92,
195         /// <summary>
196         /// The Numpad function 3 key
197         /// </summary>
198         KPF3 = 0xFF93,
199         /// <summary>
200         /// The Numpad function 4 key
201         /// </summary>
202         KPF4 = 0xFF94,
203         /// <summary>
204         /// The Numpad home key
205         /// </summary>
206         KPHome = 0xFF95,
207         /// <summary>
208         /// The Numpad left key
209         /// </summary>
210         KPLeft = 0xFF96,
211         /// <summary>
212         /// The Numpad up key
213         /// </summary>
214         KPUp = 0xFF97,
215         /// <summary>
216         /// The Numpad right key
217         /// </summary>
218         KPRight = 0xFF98,
219         /// <summary>
220         /// The Numpad down key
221         /// </summary>
222         KPDown = 0xFF99,
223         /// <summary>
224         /// The Numpad prior, previous key
225         /// </summary>
226         KPPrior = 0xFF9A,
227         /// <summary>
228         /// The Numpad page up key
229         /// </summary>
230         KPPage_Up = 0xFF9A,
231         /// <summary>
232         /// The Numpad next key
233         /// </summary>
234         KPNext = 0xFF9B,
235         /// <summary>
236         /// The Numpad page down key
237         /// </summary>
238         KPPage_Down = 0xFF9B,
239         /// <summary>
240         /// The Numpad end key
241         /// </summary>
242         KPEnd = 0xFF9C,
243         /// <summary>
244         /// The Numpad begin key
245         /// </summary>
246         KPBegin = 0xFF9D,
247         /// <summary>
248         /// The Numpad insert key
249         /// </summary>
250         KPInsert = 0xFF9E,
251         /// <summary>
252         /// The Numpad delete key
253         /// </summary>
254         KPDelete = 0xFF9F,
255         /// <summary>
256         /// The Numpad equal key
257         /// </summary>
258         KPEqual = 0xFFBD,
259         /// <summary>
260         /// The Numpad multiply key
261         /// </summary>
262         KPMultiply = 0xFFAA,
263         /// <summary>
264         /// The Numpad add key
265         /// </summary>
266         KPAdd = 0xFFAB,
267         /// <summary>
268         /// The Numpad separator key
269         /// </summary>
270         KPSeparator = 0xFFAC,
271         /// <summary>
272         /// The Numpad subtract key
273         /// </summary>
274         KPSubtract = 0xFFAD,
275         /// <summary>
276         /// The Numpad decimal key
277         /// </summary>
278         KPDecimal = 0xFFAE,
279         /// <summary>
280         /// The Numpad divide key
281         /// </summary>
282         KPDivide = 0xFFAF,
283         /// <summary>
284         /// The Numpad 0 key
285         /// </summary>
286         KP0 = 0xFFB0,
287         /// <summary>
288         /// The Numpad 1 key
289         /// </summary>
290         KP1 = 0xFFB1,
291         /// <summary>
292         /// The Numpad 2 key
293         /// </summary>
294         KP2 = 0xFFB2,
295         /// <summary>
296         /// The Numpad 3 key
297         /// </summary>
298         KP3 = 0xFFB3,
299         /// <summary>
300         /// The Numpad 4 key
301         /// </summary>
302         KP4 = 0xFFB4,
303         /// <summary>
304         /// The Numpad 5 key
305         /// </summary>
306         KP5 = 0xFFB5,
307         /// <summary>
308         /// The Numpad 6 key
309         /// </summary>
310         KP6 = 0xFFB6,
311         /// <summary>
312         /// The Numpad 7 key
313         /// </summary>
314         KP7 = 0xFFB7,
315         /// <summary>
316         /// The Numpad 8 key
317         /// </summary>
318         KP8 = 0xFFB8,
319         /// <summary>
320         /// The Numpad 9 key
321         /// </summary>
322         KP9 = 0xFFB9,
323
324         /* Auxiliary Functions */
325         /// <summary>
326         /// The function 1 key
327         /// </summary>
328         F1 = 0xFFBE,
329         /// <summary>
330         /// The function 2 key
331         /// </summary>
332         F2 = 0xFFBF,
333         /// <summary>
334         /// The function 3 key
335         /// </summary>
336         F3 = 0xFFC0,
337         /// <summary>
338         /// The function 4 key
339         /// </summary>
340         F4 = 0xFFC1,
341         /// <summary>
342         /// The function 5 key
343         /// </summary>
344         F5 = 0xFFC2,
345         /// <summary>
346         /// The function 6 key
347         /// </summary>
348         F6 = 0xFFC3,
349         /// <summary>
350         /// The function 7 key
351         /// </summary>
352         F7 = 0xFFC4,
353         /// <summary>
354         /// The function 8 key
355         /// </summary>
356         F8 = 0xFFC5,
357         /// <summary>
358         /// The function 9 key
359         /// </summary>
360         F9 = 0xFFC6,
361         /// <summary>
362         /// The function 10 key
363         /// </summary>
364         F10 = 0xFFC7,
365         /// <summary>
366         /// The function 11 key
367         /// </summary>
368         F11 = 0xFFC8,
369         /// <summary>
370         /// The function 12 key
371         /// </summary>
372         F12 = 0xFFC9,
373         /// <summary>
374         /// The function 13 key
375         /// </summary>
376         F13 = 0xFFCA,
377         /// <summary>
378         /// The function 14 key
379         /// </summary>
380         F14 = 0xFFCB,
381         /// <summary>
382         /// The function 15 key
383         /// </summary>
384         F15 = 0xFFCC,
385         /// <summary>
386         /// The function 16 key
387         /// </summary>
388         F16 = 0xFFCD,
389         /// <summary>
390         /// The function 17 key
391         /// </summary>
392         F17 = 0xFFCE,
393         /// <summary>
394         /// The function 18 key
395         /// </summary>
396         F18 = 0xFFCF,
397         /// <summary>
398         /// The function 19 key
399         /// </summary>
400         F19 = 0xFFD0,
401         /// <summary>
402         /// The function 20 key
403         /// </summary>
404         F20 = 0xFFD1,
405         /// <summary>
406         /// The function 21 key
407         /// </summary>
408         F21 = 0xFFD2,
409         /// <summary>
410         /// The function 22 key
411         /// </summary>
412         F22 = 0xFFD3,
413         /// <summary>
414         /// The function 23 key
415         /// </summary>
416         F23 = 0xFFD4,
417         /// <summary>
418         /// The function 24 key
419         /// </summary>
420         F24 = 0xFFD5,
421         /// <summary>
422         /// The function 25 key
423         /// </summary>
424         F25 = 0xFFD6,
425         /// <summary>
426         /// The function 26 key
427         /// </summary>
428         F26 = 0xFFD7,
429         /// <summary>
430         /// The function 27 key
431         /// </summary>
432         F27 = 0xFFD8,
433         /// <summary>
434         /// The function 28 key
435         /// </summary>
436         F28 = 0xFFD9,
437         /// <summary>
438         /// The function 29 key
439         /// </summary>
440         F29 = 0xFFDA,
441         /// <summary>
442         /// The function 30 key
443         /// </summary>
444         F30 = 0xFFDB,
445         /// <summary>
446         /// The function 31 key
447         /// </summary>
448         F31 = 0xFFDC,
449         /// <summary>
450         /// The function 32 key
451         /// </summary>
452         F32 = 0xFFDD,
453         /// <summary>
454         /// The function 33 key
455         /// </summary>
456         F33 = 0xFFDE,
457         /// <summary>
458         /// The function 34 key
459         /// </summary>
460         F34 = 0xFFDF,
461         /// <summary>
462         /// The function 35 key
463         /// </summary>
464         F35 = 0xFFE0,
465
466         /* Modifier keys */
467         /// <summary>
468         /// The left shift key
469         /// </summary>
470         ShiftL = 0xFFE1,
471         /// <summary>
472         /// The right shift key
473         /// </summary>
474         ShiftR = 0xFFE2,
475         /// <summary>
476         /// The left control key
477         /// </summary>
478         ControlL = 0xFFE3,
479         /// <summary>
480         /// The right control key
481         /// </summary>
482         ControlR = 0xFFE4,
483         /// <summary>
484         /// The caps lock key
485         /// </summary>
486         CapsLock = 0xFFE5,
487         /// <summary>
488         /// The shift lock key
489         /// </summary>
490         ShiftLock = 0xFFE6,
491         /// <summary>
492         /// The left meta key
493         /// </summary>
494         MetaL = 0xFFE7,
495         /// <summary>
496         /// The right meta key
497         /// </summary>
498         MetaR = 0xFFE8,
499         /// <summary>
500         /// The left alt key
501         /// </summary>
502         AltL = 0xFFE9,
503         /// <summary>
504         /// The right alt key
505         /// </summary>
506         AltR = 0xFFEA,
507         /// <summary>
508         /// The left super key
509         /// </summary>
510         SuperL = 0xFFEB,
511         /// <summary>
512         /// The right super key
513         /// </summary>
514         SuperR = 0xFFEC,
515         /// <summary>
516         /// The left hyper key
517         /// </summary>
518         HyperL = 0xFFED,
519         /// <summary>
520         /// The right hyper key
521         /// </summary>
522         HyperR = 0xFFEE,
523
524         /* Latin 1 */
525         /// <summary>
526         /// The space key
527         /// </summary>
528         Space = 0x020,
529         /// <summary>
530         /// The exclamation key
531         /// </summary>
532         Exclam = 0x021,
533         /// <summary>
534         /// The quotedbl key
535         /// </summary>
536         Quotedbl = 0x022,
537         /// <summary>
538         /// The number sign key
539         /// </summary>
540         NumberSign = 0x023,
541         /// <summary>
542         /// The dollar key
543         /// </summary>
544         Dollar = 0x024,
545         /// <summary>
546         /// The percent key
547         /// </summary>
548         Percent = 0x025,
549         /// <summary>
550         /// The ampersand key
551         /// </summary>
552         Ampersand = 0x026,
553         /// <summary>
554         /// The apostrophe key
555         /// </summary>
556         Apostrophe = 0x027,
557         /// <summary>
558         /// The parenleft key
559         /// </summary>
560         Parenleft = 0x028,
561         /// <summary>
562         /// The parenright key
563         /// </summary>
564         Parenright = 0x029,
565         /// <summary>
566         /// The asterisk key
567         /// </summary>
568         Asterisk = 0x02a,
569         /// <summary>
570         /// The plus key
571         /// </summary>
572         Plus = 0x02b,
573         /// <summary>
574         /// The comma key
575         /// </summary>
576         Comma = 0x02c,
577         /// <summary>
578         /// The minus key
579         /// </summary>
580         Minus = 0x02d,
581         /// <summary>
582         /// The period key
583         /// </summary>
584         Period = 0x02e,
585         /// <summary>
586         /// The slash key
587         /// </summary>
588         Slash = 0x02f,
589         /// <summary>
590         /// The 0 key
591         /// </summary>
592         Keypad0 = 0x030,
593         /// <summary>
594         /// The 1 key
595         /// </summary>
596         Keypad1 = 0x031,
597         /// <summary>
598         /// The 2 key
599         /// </summary>
600         Keypad2 = 0x032,
601         /// <summary>
602         /// The 3 key
603         /// </summary>
604         Keypad3 = 0x033,
605         /// <summary>
606         /// The 4 key
607         /// </summary>
608         Keypad4 = 0x034,
609         /// <summary>
610         /// The 5 key
611         /// </summary>
612         Keypad5 = 0x035,
613         /// <summary>
614         /// The 6 key
615         /// </summary>
616         Keypad6 = 0x036,
617         /// <summary>
618         /// The 7 key
619         /// </summary>
620         Keypad7 = 0x037,
621         /// <summary>
622         /// The 8 key
623         /// </summary>
624         Keypad8 = 0x038,
625         /// <summary>
626         /// The 9 key
627         /// </summary>
628         Keypad9 = 0x039,
629         /// <summary>
630         /// The colon key
631         /// </summary>
632         Colon = 0x03a,
633         /// <summary>
634         /// The semicolon key
635         /// </summary>
636         Semicolon = 0x03b,
637         /// <summary>
638         /// The less key
639         /// </summary>
640         Less = 0x03c,
641         /// <summary>
642         /// The equal key
643         /// </summary>
644         Equal = 0x03d,
645         /// <summary>
646         /// The greater key
647         /// </summary>
648         Greater = 0x03e,
649         /// <summary>
650         /// The question key
651         /// </summary>
652         Question = 0x03f,
653         /// <summary>
654         /// The at key
655         /// </summary>
656         At = 0x040,
657         /// <summary>
658         /// The A key
659         /// </summary>
660         KeypadA = 0x041,
661         /// <summary>
662         /// The B key
663         /// </summary>
664         KeypadB = 0x042,
665         /// <summary>
666         /// The C key
667         /// </summary>
668         KeypadC = 0x043,
669         /// <summary>
670         /// The D key
671         /// </summary>
672         KeypadD = 0x044,
673         /// <summary>
674         /// The E key
675         /// </summary>
676         KeypadE = 0x045,
677         /// <summary>
678         /// The F key
679         /// </summary>
680         KeypadF = 0x046,
681         /// <summary>
682         /// The G key
683         /// </summary>
684         KeypadG = 0x047,
685         /// <summary>
686         /// The H key
687         /// </summary>
688         KeypadH = 0x048,
689         /// <summary>
690         /// The I key
691         /// </summary>
692         KeypadI = 0x049,
693         /// <summary>
694         /// The J key
695         /// </summary>
696         KeypadJ = 0x04a,
697         /// <summary>
698         /// The K key
699         /// </summary>
700         KeypadK = 0x04b,
701         /// <summary>
702         /// The L key
703         /// </summary>
704         KeypadL = 0x04c,
705         /// <summary>
706         /// The M key
707         /// </summary>
708         KeypadM = 0x04d,
709         /// <summary>
710         /// The N key
711         /// </summary>
712         KeypadN = 0x04e,
713         /// <summary>
714         /// The O key
715         /// </summary>
716         KeypadO = 0x04f,
717         /// <summary>
718         /// The P key
719         /// </summary>
720         KeypadP = 0x050,
721         /// <summary>
722         /// The Q key
723         /// </summary>
724         KeypadQ = 0x051,
725         /// <summary>
726         /// The R key
727         /// </summary>
728         KeypadR = 0x052,
729         /// <summary>
730         /// The S key
731         /// </summary>
732         KeypadS = 0x053,
733         /// <summary>
734         /// The T key
735         /// </summary>
736         KeypadT = 0x054,
737         /// <summary>
738         /// The U key
739         /// </summary>
740         KeypadU = 0x055,
741         /// <summary>
742         /// The V key
743         /// </summary>
744         KeypadV = 0x056,
745         /// <summary>
746         /// The W key
747         /// </summary>
748         KeypadW = 0x057,
749         /// <summary>
750         /// The X key
751         /// </summary>
752         KeypadX = 0x058,
753         /// <summary>
754         /// The Y key
755         /// </summary>
756         KeypadY = 0x059,
757         /// <summary>
758         /// The Z key
759         /// </summary>
760         KeypadZ = 0x05a,
761         /// <summary>
762         /// The left bracket key
763         /// </summary>
764         BracketLeft = 0x05b,
765         /// <summary>
766         /// The backslash key
767         /// </summary>
768         Backslash = 0x05c,
769         /// <summary>
770         /// The right bracket key
771         /// </summary>
772         BracketRight = 0x05d,
773         /// <summary>
774         /// The circumflex key
775         /// </summary>
776         AsciiCircum = 0x05e,
777         /// <summary>
778         /// The underscore key
779         /// </summary>
780         Underscore = 0x05f,
781         /// <summary>
782         /// The grave key
783         /// </summary>
784         Grave = 0x060,
785         /// <summary>
786         /// The a key
787         /// </summary>
788         Keypada = 0x061,
789         /// <summary>
790         /// The b key
791         /// </summary>
792         Keypadb = 0x062,
793         /// <summary>
794         /// The c key
795         /// </summary>
796         Keypadc = 0x063,
797         /// <summary>
798         /// The d key
799         /// </summary>
800         Keypadd = 0x064,
801         /// <summary>
802         /// The e key
803         /// </summary>
804         Keypade = 0x065,
805         /// <summary>
806         /// The f key
807         /// </summary>
808         Keypadf = 0x066,
809         /// <summary>
810         /// The g key
811         /// </summary>
812         Keypadg = 0x067,
813         /// <summary>
814         /// The h key
815         /// </summary>
816         Keypadh = 0x068,
817         /// <summary>
818         /// The i key
819         /// </summary>
820         Keypadi = 0x069,
821         /// <summary>
822         /// The j key
823         /// </summary>
824         Keypadj = 0x06a,
825         /// <summary>
826         /// The k key
827         /// </summary>
828         Keypadk = 0x06b,
829         /// <summary>
830         /// The l key
831         /// </summary>
832         Keypadl = 0x06c,
833         /// <summary>
834         /// The m key
835         /// </summary>
836         Keypadm = 0x06d,
837         /// <summary>
838         /// The n key
839         /// </summary>
840         Keypadn = 0x06e,
841         /// <summary>
842         /// The o key
843         /// </summary>
844         Keypado = 0x06f,
845         /// <summary>
846         /// The p key
847         /// </summary>
848         Keypadp = 0x070,
849         /// <summary>
850         /// The q key
851         /// </summary>
852         Keypadq = 0x071,
853         /// <summary>
854         /// The r key
855         /// </summary>
856         Keypadr = 0x072,
857         /// <summary>
858         /// The s key
859         /// </summary>
860         Keypads = 0x073,
861         /// <summary>
862         /// The t key
863         /// </summary>
864         Keypadt = 0x074,
865         /// <summary>
866         /// The u key
867         /// </summary>
868         Keypadu = 0x075,
869         /// <summary>
870         /// The v key
871         /// </summary>
872         Keypadv = 0x076,
873         /// <summary>
874         /// The w key
875         /// </summary>
876         Keypadw = 0x077,
877         /// <summary>
878         /// The x key
879         /// </summary>
880         Keypadx = 0x078,
881         /// <summary>
882         /// The y key
883         /// </summary>
884         Keypady = 0x079,
885         /// <summary>
886         /// The z key
887         /// </summary>
888         Keypadz = 0x07a,
889         /// <summary>
890         /// The left brace key
891         /// </summary>
892         BraceLeft = 0x07b,
893         /// <summary>
894         /// The bar key
895         /// </summary>
896         Bar = 0x07c,
897         /// <summary>
898         /// The right brace key
899         /// </summary>
900         BraceRight = 0x07d,
901         /// <summary>
902         /// The tilde key
903         /// </summary>
904         AsciiTilde = 0x07e,
905     };
906
907     /// <summary>
908     /// Enumeration of the key masks.
909     /// The key masks indicate which modifier keys is pressed down during the keyboard hit.The special MASK_RELEASED indicates the key release event.
910     /// </summary>
911     /// <since_tizen> 4 </since_tizen>
912     public enum KeyMask
913     {
914         /// <summary>
915         /// Key press event without modifier key
916         /// </summary>
917         Pressed = 0,
918         /// <summary>
919         /// The Shift key is pressed down
920         /// </summary>
921         Shift = (1 << 0),
922         /// <summary>
923         /// The CapsLock key is pressed down
924         /// </summary>
925         CapsLock = (1 << 1),
926         /// <summary>
927         /// The Control key is pressed down
928         /// </summary>
929         Control = (1 << 2),
930         /// <summary>
931         /// The Alt key is pressed down
932         /// </summary>
933         Alt = (1 << 3),
934         /// <summary>
935         /// The Meta key is pressed down
936         /// </summary>
937         Meta = (1 << 4),
938         /// <summary>
939         /// The Win (between Control and Alt) is pressed down
940         /// </summary>
941         Win = (1 << 5),
942         /// <summary>
943         /// The Hyper key is pressed down
944         /// </summary>
945         Hyper = (1 << 6),
946         /// <summary>
947         /// The NumLock key is pressed down
948         /// </summary>
949         NumLock = (1 << 7),
950         /// <summary>
951         /// Key release event
952         /// </summary>
953         Released = (1 << 15),
954     }
955
956     /// <summary>
957     /// This class contains api's related to IME(Input method editor)
958     /// </summary>
959     /// <since_tizen> 4 </since_tizen>
960     public static class InputMethodEditor
961     {
962         private static Object thisLock = new Object();
963         private static ImeCallbackStructGCHandle _imeCallbackStructGCHandle = new ImeCallbackStructGCHandle();
964         private static event EventHandler<FocusedInEventArgs> _focusIn;
965         private static ImeFocusedInCb _imeFocusedInDelegate;
966         private static event EventHandler<FocusedOutEventArgs> _focusOut;
967         private static ImeFocusedOutCb _imeFocusedOutDelegate;
968         private static event EventHandler<SurroundingTextUpdatedEventArgs> _surroundingTextUpdated;
969         private static ImeSurroundingTextUpdatedCb _imeSurroundingTextUpdatedDelegate;
970         private static event EventHandler<EventArgs> _inputContextReset;
971         private static ImeInputContextResetCb _imeInputContextResetDelegate;
972         private static event EventHandler<CursorPositionUpdatedEventArgs> _cursorPositionUpdated;
973         private static ImeCursorPositionUpdatedCb _imeCursorPositionUpdatedDelegate;
974         private static event EventHandler<LanguageSetEventArgs> _langaugeSet;
975         private static ImeLanguageSetCb _imeLanguageSetDelegate;
976         private static event EventHandler<SetDataEventArgs> _imDataSet;
977         private static ImeImdataSetCb _imeDataSetDelegate;
978         private static event EventHandler<LayoutSetEventArgs> _layoutSet;
979         private static ImeLayoutSetCb _imeLayoutSetDelegate;
980         private static event EventHandler<ReturnKeySetEventArgs> _returnKeyTypeSet;
981         private static ImeReturnKeySetCb _imeReturnKeySetDelegate;
982         private static event EventHandler<ReturnKeyStateSetEventArgs> _returnKeyStateSet;
983         private static ImeReturnKeyStateSetCb _imeReturnKeyStateSetDelegate;
984         private static ImeProcessKeyEventCb _imeProcessKeyDelegate;
985         private static event EventHandler<DisplayLanguageChangedEventArgs> _displayLanguageChanged;
986         private static ImeDisplayLanguageChangedCb _imeDisplayLanguageChangedDelegate;
987         private static event EventHandler<RotationChangedEventArgs> _rotationDegreeChanged;
988         private static ImeRotationChangedCb _imeRotationChangedDelegate;
989         private static event EventHandler<AccessibilityStateChangedEventArgs> _accessibilityStateChanged;
990         private static ImeAccessibilityStateChangedCb _imeAccessibilityStateChangedDelegate;
991         private static ImeLanguageRequestedCb _imeLanguageRequestedDelegate;
992         private static OutAction<string> _languageRequestedDelegate;
993         private static BoolAction<KeyCode, KeyMask, InputMethodDeviceInformation> _processKeyDelagate;
994         private static ImeImdataRequestedCb _imeImDataRequestedDelegate;
995         private static OutArrayAction<byte> _imDataRequestedDelegate;
996         private static ImeGeometryRequestedCb _imeGeometryRequestedDelegate;
997         private static OutAction<Rect> _geometryRequestedDelegate;
998         private static Action _userCreate;
999         private static Action _userTerminate;
1000         private static Action<ContextId, InputMethodContext> _userShow;
1001         private static Action<ContextId> _userHide;
1002         private static ImeCreateCb _create = (IntPtr userData) =>
1003         {
1004             Log.Info(LogTag, "In Create Delegate");
1005             _userCreate?.Invoke();
1006         };
1007         private static ImeTerminateCb _terminate = (IntPtr userData) =>
1008         {
1009             Log.Info(LogTag, "In terminate Delegate");
1010             _userTerminate?.Invoke();
1011             _imeCallbackStructGCHandle.Dispose();
1012         };
1013         private static ImeShowCb _show = (int contextId, IntPtr context, IntPtr userData) =>
1014         {
1015             Log.Info(LogTag, "In Show Delegate");
1016             _userShow?.Invoke(new ContextId(contextId), new InputMethodContext(context));
1017         };
1018         private static ImeHideCb _hide = (int contextId, IntPtr userData) =>
1019         {
1020             Log.Info(LogTag, "In Hide Delegate");
1021             _userHide?.Invoke(new ContextId(contextId));
1022         };
1023
1024         /// <summary>
1025         /// Structure representing ContextId
1026         /// </summary>
1027         /// <since_tizen> 4 </since_tizen>
1028         public struct ContextId : IEquatable<ContextId>
1029         {
1030             internal ContextId(int id)
1031             {
1032                 Id = id;
1033             }
1034
1035             internal int Id
1036             {
1037                 get;
1038                 private set;
1039             }
1040
1041             /// <summary>
1042             /// compare whether ContextId are equal
1043             /// </summary>
1044             /// <since_tizen> 4 </since_tizen>
1045             public bool Equals(ContextId other)
1046             {
1047                 return this.Id == other.Id;
1048             }
1049         }
1050
1051         /// <summary>
1052         /// rectangle representing the position and size of UI Control
1053         /// </summary>
1054         /// <since_tizen> 4 </since_tizen>
1055         public struct Rect
1056         {
1057             /// <summary>
1058             /// The x position in screen
1059             /// </summary>
1060             /// <since_tizen> 4 </since_tizen>
1061             public int x;
1062
1063             /// <summary>
1064             /// The y position in screen
1065             /// </summary>
1066             /// <since_tizen> 4 </since_tizen>
1067             public int y;
1068
1069             /// <summary>
1070             /// The window width
1071             /// </summary>
1072             /// <since_tizen> 4 </since_tizen>
1073             public int w;
1074
1075             /// <summary>
1076             /// The window height
1077             /// </summary>
1078             /// <since_tizen> 4 </since_tizen>
1079             public int h;
1080         }
1081
1082         /// <summary>
1083         /// An Action with 1 out parameter
1084         /// </summary>
1085         /// <typeparam name="T">Generic Type</typeparam>
1086         /// <param name="a">The out parameter</param>
1087         /// <since_tizen> 4 </since_tizen>
1088         public delegate void OutAction<T>(out T a);
1089
1090         /// <summary>
1091         /// An Action with an array out parameter
1092         /// </summary>
1093         /// <typeparam name="T">Generic Type</typeparam>
1094         /// <param name="a">The out parameter 1</param>
1095         /// <since_tizen> 4 </since_tizen>
1096         public delegate void OutArrayAction<T>(out T[] a);
1097
1098         /// <summary>
1099         /// An Action with 3 Input Parameter returning a bool
1100         /// </summary>
1101         /// <typeparam name="T">Generic Type for Parameter 1</typeparam>
1102         /// <typeparam name="T1">Generic Type for Parameter 2</typeparam>
1103         /// <typeparam name="T2">Generic Type for Parameter 3</typeparam>
1104         /// <param name="a">The Input Parameter 1</param>
1105         /// <param name="b">The Input Parameter 2</param>
1106         /// <param name="c">The Input Parameter 3</param>
1107         /// <returns></returns>
1108         /// <since_tizen> 4 </since_tizen>
1109         public delegate bool BoolAction<T, T1, T2>(T a, T1 b, T2 c);
1110
1111         /// <summary>
1112         /// Called when an associated text input UI control has focus.
1113         /// </summary>
1114         /// <since_tizen> 4 </since_tizen>
1115         public static event EventHandler<FocusedInEventArgs> FocusedIn
1116         {
1117             add
1118             {
1119                 lock (thisLock)
1120                 {
1121                     _imeFocusedInDelegate = (int contextId, IntPtr userData) =>
1122                     {
1123                         FocusedInEventArgs args = new FocusedInEventArgs(contextId);
1124                         _focusIn?.Invoke(null, args);
1125                     };
1126                     ErrorCode error = ImeEventSetFocusedInCb(_imeFocusedInDelegate, IntPtr.Zero);
1127                     if (error != ErrorCode.None)
1128                     {
1129                         Log.Error(LogTag, "Add FocusedIn Failed with error " + error);
1130                     }
1131                     else
1132                     {
1133                         _focusIn += value;
1134                     }
1135                 }
1136             }
1137             remove
1138             {
1139                 lock (thisLock)
1140                 {
1141                     _focusIn -= value;
1142                 }
1143             }
1144         }
1145
1146         /// <summary>
1147         /// Called when an associated text input UI control loses focus.
1148         /// </summary>
1149         /// <since_tizen> 4 </since_tizen>
1150         public static event EventHandler<FocusedOutEventArgs> FocusedOut
1151         {
1152             add
1153             {
1154                 lock (thisLock)
1155                 {
1156                     _imeFocusedOutDelegate = (int contextId, IntPtr userData) =>
1157                     {
1158                         FocusedOutEventArgs args = new FocusedOutEventArgs(contextId);
1159                         _focusOut?.Invoke(null, args);
1160                     };
1161                     ErrorCode error = ImeEventSetFocusedOutCb(_imeFocusedOutDelegate, IntPtr.Zero);
1162                     if (error != ErrorCode.None)
1163                     {
1164                         Log.Error(LogTag, "Add FocusedOut Failed with error " + error);
1165                     }
1166                     else
1167                     {
1168                         _focusOut += value;
1169                     }
1170                 }
1171             }
1172             remove
1173             {
1174                 lock (thisLock)
1175                 {
1176                     _focusOut -= value;
1177                 }
1178             }
1179         }
1180
1181         /// <summary>
1182         /// Called when an associated text input UI control responds to a request with the surrounding text.
1183         /// </summary>
1184         /// <since_tizen> 4 </since_tizen>
1185         public static event EventHandler<SurroundingTextUpdatedEventArgs> SurroundingTextUpdated
1186         {
1187             add
1188             {
1189                 lock (thisLock)
1190                 {
1191                     _imeSurroundingTextUpdatedDelegate = (int contextId, IntPtr text, int cursorPos, IntPtr userData) =>
1192                     {
1193                         SurroundingTextUpdatedEventArgs args = new SurroundingTextUpdatedEventArgs(contextId, Marshal.PtrToStringAnsi(text), cursorPos);
1194                         _surroundingTextUpdated?.Invoke(null, args);
1195                     };
1196                     ErrorCode error = ImeEventSetSurroundingTextUpdatedCb(_imeSurroundingTextUpdatedDelegate, IntPtr.Zero);
1197                     if (error != ErrorCode.None)
1198                     {
1199                         Log.Error(LogTag, "Add SurroundingTextUpdated Failed with error " + error);
1200                     }
1201                     else
1202                     {
1203                         _surroundingTextUpdated += value;
1204                     }
1205                 }
1206             }
1207             remove
1208             {
1209                 lock (thisLock)
1210                 {
1211                     _surroundingTextUpdated -= value;
1212                 }
1213             }
1214         }
1215
1216         /// <summary>
1217         /// Called to reset the input context of an associated text input UI control.
1218         /// </summary>
1219         /// <since_tizen> 4 </since_tizen>
1220         public static event EventHandler<EventArgs> InputContextReset
1221         {
1222             add
1223             {
1224                 lock (thisLock)
1225                 {
1226                     _imeInputContextResetDelegate = (IntPtr userData) =>
1227                     {
1228                         _inputContextReset?.Invoke(null, EventArgs.Empty);
1229                     };
1230                     ErrorCode error = ImeEventSetInputContextResetCb(_imeInputContextResetDelegate, IntPtr.Zero);
1231                     if (error != ErrorCode.None)
1232                     {
1233                         Log.Error(LogTag, "Add InputContextReset Failed with error " + error);
1234                     }
1235                     else
1236                     {
1237                         _inputContextReset += value;
1238                     }
1239                 }
1240             }
1241             remove
1242             {
1243                 lock (thisLock)
1244                 {
1245                     _inputContextReset -= value;
1246                 }
1247             }
1248         }
1249
1250         /// <summary>
1251         /// Called when the position of the cursor in an associated text input UI control changes.
1252         /// </summary>
1253         /// <since_tizen> 4 </since_tizen>
1254         public static event EventHandler<CursorPositionUpdatedEventArgs> CursorPositionUpdated
1255         {
1256             add
1257             {
1258                 lock (thisLock)
1259                 {
1260                     _imeCursorPositionUpdatedDelegate = (int cursorPos, IntPtr userData) =>
1261                     {
1262                         CursorPositionUpdatedEventArgs args = new CursorPositionUpdatedEventArgs(cursorPos);
1263                         _cursorPositionUpdated?.Invoke(null, args);
1264                     };
1265                     ErrorCode error = ImeEventSetCursorPositionUpdatedCb(_imeCursorPositionUpdatedDelegate, IntPtr.Zero);
1266                     if (error != ErrorCode.None)
1267                     {
1268                         Log.Error(LogTag, "Add CursorPositionUpdated Failed with error " + error);
1269                     }
1270                     else
1271                     {
1272                         _cursorPositionUpdated += value;
1273                     }
1274                 }
1275             }
1276             remove
1277             {
1278                 lock (thisLock)
1279                 {
1280                     _cursorPositionUpdated -= value;
1281                 }
1282             }
1283         }
1284
1285         /// <summary>
1286         /// Called to set the preferred language to the input panel.
1287         /// It will be only called when the client application changes the edit field's language attribute after the input panel is shown.
1288         /// </summary>
1289         /// <since_tizen> 4 </since_tizen>
1290         public static event EventHandler<LanguageSetEventArgs> LanguageSet
1291         {
1292             add
1293             {
1294                 lock (thisLock)
1295                 {
1296                     _imeLanguageSetDelegate = (InputPanelLanguage language, IntPtr userData) =>
1297                     {
1298                         LanguageSetEventArgs args = new LanguageSetEventArgs(language);
1299                         _langaugeSet?.Invoke(null, args);
1300                     };
1301                     ErrorCode error = ImeEventSetLanguageSetCb(_imeLanguageSetDelegate, IntPtr.Zero);
1302                     if (error != ErrorCode.None)
1303                     {
1304                         Log.Error(LogTag, "Add LanguageSet Failed with error " + error);
1305                     }
1306                     else
1307                     {
1308                         _langaugeSet += value;
1309                     }
1310                 }
1311             }
1312             remove
1313             {
1314                 lock (thisLock)
1315                 {
1316                     _langaugeSet -= value;
1317                 }
1318             }
1319         }
1320
1321         /// <summary>
1322         /// Called to set the application specific data to deliver to the input panel.
1323         /// </summary>
1324         /// <since_tizen> 4 </since_tizen>
1325         public static event EventHandler<SetDataEventArgs> DataSet
1326         {
1327             add
1328             {
1329                 lock (thisLock)
1330                 {
1331                     _imeDataSetDelegate = (IntPtr data, uint dataLength, IntPtr userData) =>
1332                     {
1333                         byte[] destination = new byte[dataLength];
1334                         Marshal.Copy(data, destination, 0, (int)dataLength);
1335                         SetDataEventArgs args = new SetDataEventArgs(destination, dataLength);
1336                         _imDataSet?.Invoke(null, args);
1337                     };
1338                     ErrorCode error = ImeEventSetImdataSetCb(_imeDataSetDelegate, IntPtr.Zero);
1339                     if (error != ErrorCode.None)
1340                     {
1341                         Log.Error(LogTag, "Add DataSet Failed with error " + error);
1342                     }
1343                     else
1344                     {
1345                         _imDataSet += value;
1346                     }
1347                 }
1348             }
1349             remove
1350             {
1351                 lock (thisLock)
1352                 {
1353                     _imDataSet -= value;
1354                 }
1355             }
1356         }
1357
1358         /// <summary>
1359         /// Called when an associated text input UI control requests the input panel to set its layout.
1360         /// It will be only called when the client application changes the edit field's layout attribute after the input panel is shown.
1361         /// </summary>
1362         /// <since_tizen> 4 </since_tizen>
1363         public static event EventHandler<LayoutSetEventArgs> LayoutSet
1364         {
1365             add
1366             {
1367                 lock (thisLock)
1368                 {
1369                     _imeLayoutSetDelegate = (InputPanelLayout layout, IntPtr userData) =>
1370                     {
1371                         LayoutSetEventArgs args = new LayoutSetEventArgs(layout);
1372                         _layoutSet?.Invoke(null, args);
1373                     };
1374                     ErrorCode error = ImeEventSetLayoutSetCb(_imeLayoutSetDelegate, IntPtr.Zero);
1375                     if (error != ErrorCode.None)
1376                     {
1377                         Log.Error(LogTag, "Add LayoutSet Failed with error " + error);
1378                     }
1379                     else
1380                     {
1381                         _layoutSet += value;
1382                     }
1383                 }
1384             }
1385             remove
1386             {
1387                 lock (thisLock)
1388                 {
1389                     _layoutSet -= value;
1390                 }
1391             }
1392         }
1393
1394         /// <summary>
1395         /// Called when an associated text input UI control requests the input panel to set the Return key label.
1396         /// The input panel can show text or image on the Return button according to the Return key action.
1397         /// </summary>
1398         /// <since_tizen> 4 </since_tizen>
1399         public static event EventHandler<ReturnKeySetEventArgs> ReturnKeySet
1400         {
1401             add
1402             {
1403                 lock (thisLock)
1404                 {
1405                     _imeReturnKeySetDelegate = (InputPanelReturnKey type, IntPtr userData) =>
1406                     {
1407                         ReturnKeySetEventArgs args = new ReturnKeySetEventArgs(type);
1408                         _returnKeyTypeSet?.Invoke(null, args);
1409                     };
1410                     ErrorCode error = ImeEventSetReturnKeySetCb(_imeReturnKeySetDelegate, IntPtr.Zero);
1411                     if (error != ErrorCode.None)
1412                     {
1413                         Log.Error(LogTag, "Add ReturnKeySet Failed with error " + error);
1414                     }
1415                     else
1416                     {
1417                         _returnKeyTypeSet += value;
1418                     }
1419                 }
1420             }
1421             remove
1422             {
1423                 lock (thisLock)
1424                 {
1425                     _returnKeyTypeSet -= value;
1426                 }
1427             }
1428         }
1429
1430         /// <summary>
1431         /// Called when an associated text input UI control requests the input panel to enable or disable the Return key state.
1432         /// </summary>
1433         /// <since_tizen> 4 </since_tizen>
1434         public static event EventHandler<ReturnKeyStateSetEventArgs> ReturnKeyStateSet
1435         {
1436             add
1437             {
1438                 lock (thisLock)
1439                 {
1440                     _imeReturnKeyStateSetDelegate = (bool state, IntPtr userData) =>
1441                     {
1442                         ReturnKeyStateSetEventArgs args = new ReturnKeyStateSetEventArgs(state);
1443                         _returnKeyStateSet?.Invoke(null, args);
1444                     };
1445                     ErrorCode error = ImeEventSetReturnKeyStateSetCb(_imeReturnKeyStateSetDelegate, IntPtr.Zero);
1446                     if (error != ErrorCode.None)
1447                     {
1448                         Log.Error(LogTag, "Add ReturnKeyStateSet Failed with error " + error);
1449                     }
1450                     else
1451                     {
1452                         _returnKeyStateSet += value;
1453                     }
1454                 }
1455             }
1456             remove
1457             {
1458                 lock (thisLock)
1459                 {
1460                     _returnKeyStateSet -= value;
1461                 }
1462             }
1463         }
1464
1465         /// <summary>
1466         /// Called when the system display Language is changed.
1467         /// </summary>
1468         /// <since_tizen> 4 </since_tizen>
1469         public static event EventHandler<DisplayLanguageChangedEventArgs> DisplayLanguageChanged
1470         {
1471             add
1472             {
1473                 lock (thisLock)
1474                 {
1475                     _imeDisplayLanguageChangedDelegate = (IntPtr language, IntPtr userData) =>
1476                     {
1477                         DisplayLanguageChangedEventArgs args = new DisplayLanguageChangedEventArgs(Marshal.PtrToStringAnsi(language));
1478                         _displayLanguageChanged?.Invoke(null, args);
1479                     };
1480                     ErrorCode error = ImeEventSetDisplayLanguageChangedCb(_imeDisplayLanguageChangedDelegate, IntPtr.Zero);
1481                     if (error != ErrorCode.None)
1482                     {
1483                         Log.Error(LogTag, "Add DisplayLanguageChanged Failed with error " + error);
1484                     }
1485                     else
1486                     {
1487                         _displayLanguageChanged += value;
1488                     }
1489                 }
1490             }
1491             remove
1492             {
1493                 lock (thisLock)
1494                 {
1495                     _displayLanguageChanged -= value;
1496                 }
1497             }
1498         }
1499
1500         /// <summary>
1501         /// Called when the device is rotated.
1502         /// </summary>
1503         /// <since_tizen> 4 </since_tizen>
1504         public static event EventHandler<RotationChangedEventArgs> RotationChanged
1505         {
1506             add
1507             {
1508                 lock (thisLock)
1509                 {
1510                     _imeRotationChangedDelegate = (int degree, IntPtr userData) =>
1511                     {
1512                         RotationChangedEventArgs args = new RotationChangedEventArgs(degree);
1513                         _rotationDegreeChanged?.Invoke(null, args);
1514                     };
1515                     ErrorCode error = ImeEventSetRotationChangedCb(_imeRotationChangedDelegate, IntPtr.Zero);
1516                     if (error != ErrorCode.None)
1517                     {
1518                         Log.Error(LogTag, "Add RotationChanged Failed with error " + error);
1519                     }
1520                     else
1521                     {
1522                         _rotationDegreeChanged += value;
1523                     }
1524                 }
1525             }
1526             remove
1527             {
1528                 lock (thisLock)
1529                 {
1530                     _rotationDegreeChanged -= value;
1531                 }
1532             }
1533         }
1534
1535         /// <summary>
1536         /// Called when Accessibility in Settings application is on or off.
1537         /// </summary>
1538         /// <since_tizen> 4 </since_tizen>
1539         public static event EventHandler<AccessibilityStateChangedEventArgs> AccessibilityStateChanged
1540         {
1541             add
1542             {
1543                 lock (thisLock)
1544                 {
1545                     _imeAccessibilityStateChangedDelegate = (bool state, IntPtr userData) =>
1546                     {
1547                         AccessibilityStateChangedEventArgs args = new AccessibilityStateChangedEventArgs(state);
1548                         _accessibilityStateChanged?.Invoke(null, args);
1549                     };
1550                     ErrorCode error = ImeEventSetAccessibilityStateChangedCb(_imeAccessibilityStateChangedDelegate, IntPtr.Zero);
1551                     if (error != ErrorCode.None)
1552                     {
1553                         Log.Error(LogTag, "Add AccessibilityStateChanged Failed with error " + error);
1554                     }
1555                     else
1556                     {
1557                         _accessibilityStateChanged += value;
1558                     }
1559                 }
1560             }
1561             remove
1562             {
1563                 lock (thisLock)
1564                 {
1565                     _accessibilityStateChanged -= value;
1566                 }
1567             }
1568         }
1569
1570         /// <summary>
1571         /// Sets the languageRequested Action
1572         /// </summary>
1573         /// <param name="languageRequested">
1574         /// Called when an associated text input UI control requests the language from the input panel, requesting for language code.
1575         /// </param>
1576         /// <since_tizen> 4 </since_tizen>
1577         public static void SetLanguageRequestedCallback(OutAction<string> languageRequested)
1578         {
1579             _imeLanguageRequestedDelegate = (IntPtr userData, out IntPtr langCode) =>
1580             {
1581                 string langauage;
1582                 _languageRequestedDelegate(out langauage);
1583                 char[] languageArray = langauage.ToCharArray();
1584                 langCode = new IntPtr();
1585                 Marshal.Copy(languageArray, 0, langCode, languageArray.Length);
1586             };
1587             ErrorCode error = ImeEventSetLanguageRequestedCallbackCb(_imeLanguageRequestedDelegate, IntPtr.Zero);
1588             if (error != ErrorCode.None)
1589             {
1590                 Log.Error(LogTag, "Add SetLanguageRequestedCallback Failed with error " + error);
1591             }
1592             _languageRequestedDelegate = languageRequested;
1593         }
1594
1595         /// <summary>
1596         /// Sets the processKey Action
1597         /// If the key event is from the external device, DeviceInfo will have its name, class and subclass information.
1598         /// </summary>
1599         /// <param name="processKey">
1600         /// The Action is alled when the key event is received from the external devices or SendKey function.
1601         /// This Event processes the key event before an associated text input UI control does.
1602         /// </param>
1603         /// <since_tizen> 4 </since_tizen>
1604         public static void SetProcessKeyCallback(BoolAction<KeyCode, KeyMask, InputMethodDeviceInformation> processKey)
1605         {
1606             _imeProcessKeyDelegate = (KeyCode keyCode, KeyMask keyMask, IntPtr devInfo, IntPtr userData) =>
1607             {
1608                 return _processKeyDelagate(keyCode, keyMask, new InputMethodDeviceInformation(devInfo));
1609             };
1610             ErrorCode error = ImeEventSetProcessKeyEventCb(_imeProcessKeyDelegate, IntPtr.Zero);
1611             if (error != ErrorCode.None)
1612             {
1613                 Log.Error(LogTag, "Add ProcessKey Failed with error " + error);
1614             }
1615             _processKeyDelagate = processKey;
1616         }
1617
1618         /// <summary>
1619         /// Sets the imDataRequested Action
1620         /// </summary>
1621         /// <param name="imDataRequested">
1622         /// Called when an associated text input UI control requests the application specific data from the input panel, requesting for data array and it's length.
1623         /// </param>
1624         /// <since_tizen> 4 </since_tizen>
1625         public static void SetDataRequestedCallback(OutArrayAction<byte> imDataRequested)
1626         {
1627             _imeImDataRequestedDelegate = (IntPtr userData, out IntPtr data, out uint dataLength) =>
1628             {
1629                 byte[] dataArr;
1630                 _imDataRequestedDelegate(out dataArr);
1631                 data = new IntPtr();
1632                 Marshal.Copy(dataArr, 0, data, dataArr.Length);
1633                 dataLength = (uint)dataArr.Length;
1634             };
1635             ErrorCode error = ImeEventSetImdataRequestedCb(_imeImDataRequestedDelegate, IntPtr.Zero);
1636             if (error != ErrorCode.None)
1637             {
1638                 Log.Error(LogTag, "Add SetDataRequestedCallback Failed with error " + error);
1639             }
1640             _imDataRequestedDelegate = imDataRequested;
1641         }
1642
1643         /// <summary>
1644         /// Sets the GeometryRequested Action
1645         /// </summary>
1646         /// <param name="geometryRequested">
1647         /// Called when an associated text input UI control requests the position and size from the input panel, requesting for x,y,w,h values.
1648         /// </param>
1649         /// <since_tizen> 4 </since_tizen>
1650         public static void SetGeometryRequestedCallback(OutAction<Rect> geometryRequested)
1651         {
1652             _imeGeometryRequestedDelegate = (IntPtr userData, out int x, out int y, out int w, out int h) =>
1653             {
1654                 Rect rect = new Rect();
1655                 _geometryRequestedDelegate(out rect);
1656                 x = rect.x;
1657                 y = rect.y;
1658                 w = rect.w;
1659                 h = rect.h;
1660             };
1661             ErrorCode error = ImeEventSetGeometryRequestedCallbackCb(_imeGeometryRequestedDelegate, IntPtr.Zero);
1662             if (error != ErrorCode.None)
1663             {
1664                 Log.Error(LogTag, "Add SetGeometryRequestedCallback Failed with error " + error);
1665             }
1666             _geometryRequestedDelegate = geometryRequested;
1667         }
1668
1669         /// <summary>
1670         /// Runs the main loop of IME application.
1671         /// This function starts to run IME application's main loop.
1672         /// </summary>
1673         /// <privilege>
1674         /// http://tizen.org/privilege/ime
1675         /// </privilege>
1676         /// <remarks>
1677         /// This API is a blocking call, as it starts the main loop of the application.
1678         /// </remarks>
1679         /// <param name="create">This is called to initialize IME application before the main loop starts up</param>
1680         /// <param name="terminate">This is called when IME application is terminated</param>
1681         /// <param name="show">
1682         /// This is called when IME application is shown
1683         /// It provides the Context Information and the Context Id
1684         /// </param>
1685         /// <param name="hide">
1686         /// This is called when IME application is hidden
1687         /// It provides the Context Id
1688         /// </param>
1689         /// <exception cref="InvalidOperationException">
1690         /// This can occur due to the following reasons:
1691         /// 1) The application does not have the privilege to call this function
1692         /// 2) Operation failed
1693         /// </exception>
1694         /// <since_tizen> 4 </since_tizen>
1695         public static void Run(Action create, Action terminate, Action<ContextId, InputMethodContext> show, Action<ContextId> hide)
1696         {
1697             _userCreate = create;
1698             _userTerminate = terminate;
1699             _userShow = show;
1700             _userHide = hide;
1701             _imeCallbackStructGCHandle._imeCallbackStruct.create = _create;
1702             _imeCallbackStructGCHandle._imeCallbackStruct.terminate = _terminate;
1703             _imeCallbackStructGCHandle._imeCallbackStruct.hide = _hide;
1704             _imeCallbackStructGCHandle._imeCallbackStruct.show = _show;
1705
1706             ErrorCode error = ImeRun(ref _imeCallbackStructGCHandle._imeCallbackStruct, IntPtr.Zero);
1707             if (error != ErrorCode.None)
1708             {
1709                 Log.Error(LogTag, "Run Failed with error " + error);
1710                 throw InputMethodExceptionFactory.CreateException(error);
1711             }
1712
1713         }
1714
1715         /// <summary>
1716         /// Sends a key event to the associated text input UI control.
1717         /// </summary>
1718         /// <remarks>
1719         /// This function sends key down or up event with key mask to the client application. If forwardKey is true, this key event goes to the edit filed directly.
1720         /// And if forwardKey is false, the ProcessKey event receives the key event before the edit field.
1721         /// </remarks>
1722         /// <privilege>
1723         /// http://tizen.org/privilege/ime
1724         /// </privilege>
1725         /// <param name="keyCode">The key code to be sent</param>
1726         /// <param name="keyMask">The modifier key mask</param>
1727         /// <param name="forwardKey">The flag to send the key event directly to the edit field</param>
1728         /// <exception cref="InvalidOperationException">
1729         /// This can occur due to the following reasons:
1730         /// 1) The application does not have the privilege to call this function
1731         /// 2) IME main loop isn't started yet
1732         /// </exception>
1733         /// <since_tizen> 4 </since_tizen>
1734         public static void SendKeyEvent(KeyCode keyCode, KeyMask keyMask, bool forwardKey = false)
1735         {
1736             ErrorCode error = ImeSendKeyEvent(keyCode, keyMask, forwardKey);
1737             if (error != ErrorCode.None)
1738             {
1739                 Log.Error(LogTag, "SendEvent Failed with error " + error);
1740                 throw InputMethodExceptionFactory.CreateException(error);
1741             }
1742         }
1743
1744         /// <summary>
1745         /// Sends the text to the associated text input UI control.
1746         /// </summary>
1747         /// <privilege>
1748         /// http://tizen.org/privilege/ime
1749         /// </privilege>
1750         /// <param name="str">The string to be committed</param>
1751         /// <exception cref="InvalidOperationException">
1752         /// This can occur due to the following reasons:
1753         /// 1) The application does not have the privilege to call this function
1754         /// 2) IME main loop isn't started yet
1755         /// </exception>
1756         /// <since_tizen> 4 </since_tizen>
1757         public static void CommitString(string str)
1758         {
1759             ErrorCode error = ImeCommitString(str);
1760             if (error != ErrorCode.None)
1761             {
1762                 Log.Error(LogTag, "CommitString Failed with error " + error);
1763                 throw InputMethodExceptionFactory.CreateException(error);
1764             }
1765         }
1766
1767         /// <summary>
1768         /// Requests to show preedit string.
1769         /// </summary>
1770         /// <privilege>
1771         /// http://tizen.org/privilege/ime
1772         /// </privilege>
1773         /// <exception cref="InvalidOperationException">
1774         /// This can occur due to the following reasons:
1775         /// 1) The application does not have the privilege to call this function
1776         /// 2) IME main loop isn't started yet
1777         /// </exception>
1778         /// <since_tizen> 4 </since_tizen>
1779         public static void ShowPreEditString()
1780         {
1781             ErrorCode error = ImeShowPreeditString();
1782             if (error != ErrorCode.None)
1783             {
1784                 Log.Error(LogTag, "ShowPreEditString Failed with error " + error);
1785                 throw InputMethodExceptionFactory.CreateException(error);
1786             }
1787         }
1788
1789         /// <summary>
1790         /// Requests to hide preedit string.
1791         /// </summary>
1792         /// <privilege>
1793         /// http://tizen.org/privilege/ime
1794         /// </privilege>
1795         /// <exception cref="InvalidOperationException">
1796         /// This can occur due to the following reasons:
1797         /// 1) The application does not have the privilege to call this function
1798         /// 2) IME main loop isn't started yet
1799         /// </exception>
1800         /// <since_tizen> 4 </since_tizen>
1801         public static void HidePreEditString()
1802         {
1803             ErrorCode error = ImeHidePreeditString();
1804             if (error != ErrorCode.None)
1805             {
1806                 Log.Error(LogTag, "HidePreEditString Failed with error " + error);
1807                 throw InputMethodExceptionFactory.CreateException(error);
1808             }
1809         }
1810
1811         /// <summary>
1812         /// Updates a new preedit string.
1813         /// </summary>
1814         /// <privilege>
1815         /// http://tizen.org/privilege/ime
1816         /// </privilege>
1817         /// <param name="str">The string to be updated in preedit</param>
1818         /// <param name="attrs">
1819         /// The list which has ime_preedit_attribute lists, strings can be composed of multiple string attributes: underline, highlight color and reversal color.
1820         /// The attrs list can be empty if no attributes to set
1821         /// </param>
1822         /// <exception cref="InvalidOperationException">
1823         /// This can occur due to the following reasons:
1824         /// 1) The application does not have the privilege to call this function
1825         /// 2) IME main loop isn't started yet
1826         /// 3) Invalid Parameter
1827         /// </exception>
1828         /// <since_tizen> 4 </since_tizen>
1829         public static void UpdatePreEditString(string str, IEnumerable<PreEditAttribute> attrs)
1830         {
1831             IntPtr einaList = IntPtr.Zero;
1832             List<GCHandle> attributeHandleList = new List<GCHandle>();
1833             foreach (PreEditAttribute attribute in attrs)
1834             {
1835                 ImePreEditAttributeStruct imePreEditAttribute = new ImePreEditAttributeStruct();
1836                 imePreEditAttribute.start = attribute.Start;
1837                 imePreEditAttribute.length = attribute.Length;
1838                 imePreEditAttribute.type = (int)attribute.Type;
1839                 imePreEditAttribute.value = attribute.Value;
1840                 GCHandle attributeHandle = GCHandle.Alloc(imePreEditAttribute, GCHandleType.Pinned);
1841                 attributeHandleList.Add(attributeHandle);
1842                 einaList = Interop.EinaList.EinaListAppend(einaList, attributeHandle.AddrOfPinnedObject());
1843             }
1844             ErrorCode error = ImeUpdatePreeditString(str, einaList);
1845             foreach (GCHandle handle in attributeHandleList)
1846             {
1847                 handle.Free();
1848             }
1849             if (error != ErrorCode.None)
1850             {
1851                 Log.Error(LogTag, "UpdatePreEditString Failed with error " + error);
1852                 throw InputMethodExceptionFactory.CreateException(error);
1853             }
1854         }
1855
1856         /// <summary>
1857         /// Requests the surrounding text from the position of the cursor, asynchronously.
1858         /// </summary>
1859         /// <privilege>
1860         /// http://tizen.org/privilege/ime
1861         /// </privilege>
1862         /// <param name="maxLenBefore">The maximum length of string to be retrieved before the cursor, -1 means unlimited</param>
1863         /// <param name="maxLenAfter">The maximum length of string to be retrieved after the cursor, -1 means unlimited</param>
1864         /// <exception cref="InvalidOperationException">
1865         /// This can occur due to the following reasons:
1866         /// 1) The application does not have the privilege to call this function
1867         /// 2) IME main loop isn't started yet
1868         /// </exception>
1869         /// <postcondition>
1870         /// The requested surrounding text can be received using the SurroundingTextUpdated Event, only if it is set.
1871         /// </postcondition>
1872         /// <since_tizen> 4 </since_tizen>
1873         public static void RequestSurroundingText(int maxLenBefore, int maxLenAfter)
1874         {
1875             ErrorCode error = ImeRequestSurroundingText(maxLenBefore, maxLenAfter);
1876             if (error != ErrorCode.None)
1877             {
1878                 Log.Error(LogTag, "RequestSurroundingText Failed with error " + error);
1879                 throw InputMethodExceptionFactory.CreateException(error);
1880             }
1881         }
1882
1883         /// <summary>
1884         /// Requests to delete surrounding text.
1885         /// </summary>
1886         /// <privilege>
1887         /// http://tizen.org/privilege/ime
1888         /// </privilege>
1889         /// <param name="offset">The offset value from the cursor position</param>
1890         /// <param name="len">The length of the text to delete</param>
1891         /// <exception cref="InvalidOperationException">
1892         /// This can occur due to the following reasons:
1893         /// 1) The application does not have the privilege to call this function
1894         /// 2) IME main loop isn't started yet
1895         /// 3) Invalid Parameter
1896         /// </exception>
1897         /// <since_tizen> 4 </since_tizen>
1898         public static void DeleteSurroundingText(int offset, int len)
1899         {
1900             ErrorCode error = ImeDeleteSurroundingText(offset, len);
1901             if (error != ErrorCode.None)
1902             {
1903                 Log.Error(LogTag, "DeleteSurroundingText Failed with error " + error);
1904                 throw InputMethodExceptionFactory.CreateException(error);
1905             }
1906         }
1907
1908         /// <summary>
1909         /// Gets the surrounding text from the position of the cursor, synchronously.
1910         /// </summary>
1911         /// <privilege>
1912         /// http://tizen.org/privilege/ime
1913         /// </privilege>
1914         /// <param name="maxLenBefore">The maximum length of string to be retrieved before the cursor, -1 means unlimited</param>
1915         /// <param name="maxLenAfter">The maximum length of string to be retrieved after the cursor, -1 means unlimited</param>
1916         /// <param name="text">The surrounding text</param>
1917         /// <param name="cursorPosition">The cursor position</param>
1918         /// <exception cref="InvalidOperationException">
1919         /// This can occur due to the following reasons:
1920         /// 1) The application does not have the privilege to call this function
1921         /// 2) IME main loop isn't started yet
1922         /// 3) Invalid Parameter
1923         /// 4) Failed to obtain text due to out of memory
1924         /// </exception>
1925         /// <since_tizen> 4 </since_tizen>
1926         public static void GetSurroundingText(int maxLenBefore, int maxLenAfter, out string text, out int cursorPosition)
1927         {
1928             IntPtr txt;
1929             ErrorCode error = ImeGetSurroundingText(maxLenBefore, maxLenAfter, out txt, out cursorPosition);
1930             if (error != ErrorCode.None)
1931             {
1932                 Log.Error(LogTag, "GetSurroundingText Failed with error " + error);
1933                 throw InputMethodExceptionFactory.CreateException(error);
1934             }
1935             text = Marshal.PtrToStringAnsi(txt);
1936         }
1937
1938         /// <summary>
1939         /// Requests to set selection.
1940         /// </summary>
1941         /// <privilege>
1942         /// http://tizen.org/privilege/ime
1943         /// </privilege>
1944         /// <param name="start">The start cursor position in text (in characters not bytes)</param>
1945         /// <param name="end">The end cursor position in text (in characters not bytes)</param>
1946         /// <exception cref="InvalidOperationException">
1947         /// This can occur due to the following reasons:
1948         /// 1) The application does not have the privilege to call this function
1949         /// 2) IME main loop isn't started yet
1950         /// 3) Invalid Parameter
1951         /// </exception>
1952         /// <since_tizen> 4 </since_tizen>
1953         public static void SetSelection(int start, int end)
1954         {
1955             ErrorCode error = ImeSetSelection(start, end);
1956             if (error != ErrorCode.None)
1957             {
1958                 Log.Error(LogTag, "SetSelection Failed with error " + error);
1959                 throw InputMethodExceptionFactory.CreateException(error);
1960             }
1961         }
1962
1963         /// <summary>
1964         /// This API returns the input panel main window.
1965         /// </summary>
1966         /// <privilege>
1967         /// http://tizen.org/privilege/ime
1968         /// </privilege>
1969         /// <returns>The input panel main window object on success, otherwise null</returns>
1970         /// <exception cref="InvalidOperationException">
1971         /// This can occur due to the following reasons:
1972         /// 1) The application does not have the privilege to call this function
1973         /// 2) IME main loop isn't started yet
1974         /// 3) Operation Failed
1975         /// </exception>
1976         /// <since_tizen> 4 </since_tizen>
1977         public static EditorWindow GetMainWindow()
1978         {
1979             EditorWindow._handle = ImeGetMainWindow();
1980             EditorWindow obj = new EditorWindow();
1981             ErrorCode error = (ErrorCode)Tizen.Internals.Errors.ErrorFacts.GetLastResult();
1982             if (error != ErrorCode.None)
1983             {
1984                 Log.Error(LogTag, "GetMainWindow Failed with error " + error);
1985                 throw InputMethodExceptionFactory.CreateException(error);
1986             }
1987             return obj;
1988         }
1989
1990         /// <summary>
1991         /// This API requests the InputMethodEditor to initialize
1992         /// </summary>
1993         /// <privilege>
1994         /// http://tizen.org/privilege/ime
1995         /// </privilege>
1996         /// <exception cref="InvalidOperationException">
1997         /// This can occur due to the following reasons:
1998         /// 1) The application does not have the privilege to call this function
1999         /// 2) Operation Failed
2000         /// </exception>
2001         /// <since_tizen> 4 </since_tizen>
2002         public static void Create()
2003         {
2004             ErrorCode error = ImeInitialize();
2005             Log.Info(LogTag, "ImeInitialize result : " + error);
2006             if (error != ErrorCode.None)
2007             {
2008                 Log.Error(LogTag, "ImeInitialize Failed with error " + error);
2009                 throw InputMethodExceptionFactory.CreateException(error);
2010             }
2011
2012             error = ImePrepare();
2013             Log.Info(LogTag, "ImePrepare result : " + error);
2014             if (error != ErrorCode.None)
2015             {
2016                 Log.Error(LogTag, "ImePrepare Failed with error " + error);
2017                 throw InputMethodExceptionFactory.CreateException(error);
2018             }
2019         }
2020
2021         /// <summary>
2022         /// This API requests the InputMethodEditor to finalize
2023         /// </summary>
2024         /// <privilege>
2025         /// http://tizen.org/privilege/ime
2026         /// </privilege>
2027         /// <exception cref="InvalidOperationException">
2028         /// This can occur due to the following reasons:
2029         /// 1) The application does not have the privilege to call this function
2030         /// 2) Operation Failed
2031         /// </exception>
2032         /// <since_tizen> 4 </since_tizen>
2033         public static void Destroy()
2034         {
2035             ErrorCode error = ImeFinalize();
2036             Log.Info(LogTag, "ImeFinalize result : " + error);
2037             if (error != ErrorCode.None)
2038             {
2039                 Log.Error(LogTag, "ImeFinalize Failed with error " + error);
2040                 throw InputMethodExceptionFactory.CreateException(error);
2041             }
2042         }
2043     }
2044 }