This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 225
Expand file tree
/
Copy pathandroidfield.lcb
More file actions
1808 lines (1480 loc) · 59.6 KB
/
androidfield.lcb
File metadata and controls
1808 lines (1480 loc) · 59.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (C) 2017 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
/**
This widget is a native field on Android.
Name: enabled
Type: property
Summary: Whether the field is active and responds to user action
Syntax:
set the enabled of <widget> to {true | false}
get the enabled of <widget>
Description:
Use the <enabled> property to enable or disable the native field. When disabled,
the field has a greyed out appearance.
Name: openField
Type: message
Summary: Sent to an unlocked field when you click or select text in that field.
Syntax: openField
Example:
on openField -- when clicking in the field, select all its text
local tText
put the text of the target into tText
set the selectedRange of the target to "1," & \
the number of chars in tText
end openField
Description:
Handle the <openField> message if you want to do something when the user enters
a field widget. The message is not sent if the field is locked.
Name: closeField
Type: message
Summary:
Sent to a field when the focus is being removed from that field and the field's
content has changed.
Syntax: closeField
Example:
on closeField -- make sure the user has entered a valid date
local tText
put the text of me into tText
if tText is not a date then
beep
answer "Please enter a date."
set the selectedRange of the target to "1," & \
the number of chars in tText
end if
end closeField
Description:
Handle the <closeField> message if you want to make sure a field's content is
correct after it has been changed.
Name: exitField
Type: message
Summary:
Sent to the field with the selection when the selection is being removed from
the field, and its contents have not changed.
Syntax: exitField
Example:
on exitField -- remove visual signs that the field is being edited
set the enabled of the target to false
end exitField
Description:
Handle the <exitField> message if you want to do something when the user leaves
a field that hasn't been changed.
Name: textChanged
Type: message
Summary:
Sent when the native field widget text is changed.
Syntax: textChanged
Example:
on textChanged
if the text of me is not a number then
beep
end if
end textChanged
Description:
Handle the <textChanged> message if you want to do something when the text of
the field is changed through typing.
*/
widget com.livecode.widget.native.android.field
use com.livecode.foreign
use com.livecode.java
use com.livecode.widget
use com.livecode.canvas
use com.livecode.engine
use com.livecode.library.widgetutils
use com.livecode.library.androidutils
use com.livecode.library.scriptitems
metadata version is "1.0.0"
metadata author is "LiveCode"
metadata title is "Android Native Field"
metadata os is "android"
metadata svgicon is "M28.06,4.95a.34.34,0,1,1,.34.34A.34.34,0,0,1,28.06,4.95Zm-3.45.34a.34.34,0,1,0-.34-.34A.34.34,0,0,0,24.6,5.29ZM36.25,2V17.24a2,2,0,0,1-2,2H2a2,2,0,0,1-2-2V2A2,2,0,0,1,2,0h32.3A2,2,0,0,1,36.25,2ZM22.39,6.8h8.23a3.76,3.76,0,0,0-2.1-3.31l.65-1.17a.13.13,0,0,0-.05-.18l-.06,0a.13.13,0,0,0-.11.07l-.66,1.19a4.43,4.43,0,0,0-3.56,0l-.66-1.19a.13.13,0,1,0-.23.13l.65,1.17A3.76,3.76,0,0,0,22.39,6.8ZM9.57,2.57H5v1.5H6.53v11H5v1.5H9.57v-1.5H8v-11H9.57ZM22,7.89a.92.92,0,0,0-1.84,0v3.84a.92.92,0,1,0,1.84,0Zm8.57-.76H22.39v6a1,1,0,0,0,1,1H24v2a.92.92,0,1,0,1.84,0v-2h1.23v2a.92.92,0,1,0,1.84,0v-2h.66a1,1,0,0,0,1-1Zm2.19.76a.92.92,0,0,0-1.84,0v3.84a.92.92,0,1,0,1.84,0Z"
__safe foreign handler _JNI_GetSystemService(in pContext as JObject, in pService as JString) returns JObject \
binds to "java:android.content.Context>getSystemService(Ljava/lang/String;)Ljava/lang/Object;"
// Handlers for creating and attaching view
__safe foreign handler _JNI_CreateView(in pContext as JObject) returns JObject \
binds to "java:android.widget.EditText>new(Landroid/content/Context;)V?ui"
private variable mNativeObj as optional JObject
private variable mIMMObj as optional JObject
// We need to store all properties as variables so they can be set in the IDE
// and persist when saved
private variable mText as String
private variable mTextColor as String
private variable mTextAlign as String
private variable mVerticalTextAlign as String
private variable mAutoCapitalizationType as String
private variable mAutoCorrectionType as String
private variable mKeyboardType as String
private variable mReturnKeyType as String
private variable mContentType as String
private variable mDataDetectorTypes as String
private variable mMultiline as Boolean
private variable mEditable as Boolean
private variable mScrollingEnabled as Boolean
private variable mPassReturnKey as Boolean
// Properties
/**
Syntax:
set the text of <widget> to <pText>
get the text of <widget>
Summary: The text contained in the field widget.
Value (string): A string.
Example:
set the text of widget "Android Field" to "Some text"
Description:
Use the <text> property to change the text of the field widget.
*/
property "text" get GetText set SetText
metadata text.section is "Contents"
metadata text.user_visible is "true"
metadata text.default is ""
/**
Syntax:
set the fieldTextColor of <widget> to <pColor>
get the fieldTextColor of <widget>
Summary: The color of the text of the field widget.
Value (string):
A comma delimited string representing a color in RGB / RGBA format
Example:
set the fieldTextColor of widget "Android Field" to "255,0,0,128"
Description:
Use the <fieldTextColor> property to change the color of the text of the field
widget.
*/
property fieldTextColor get GetTextColor set SetTextColor
metadata fieldTextColor.editor is "com.livecode.pi.colorwithalpha"
metadata fieldTextColor.label is "Text color"
metadata fieldTextColor.default is "0,0,0,255"
metadata fieldTextColor.section is "Colors"
/**
Name: textSize
Type: property
Syntax:
set the textSize of <widget> to <pSize>
get the textSize of <widget>
Summary: The size in points of the text of the field widget.
Value (number): A non-negative number
Example:
set the textSize of widget "Android Field" to 18
Description:
Use the <textSize> property to change the size of the text of the field widget.
*/
metadata textSize.dummy is ""
/**
Syntax:
set the textAlign of <widget> to <pAlign>
get the textAlign of <widget>
Summary: The horizontal text alignment of the field widget.
Value (enum):
- "left": Left-aligned text
- "center": Center-aligned text
- "right": Right-aligned text
Example:
set the textAlign of widget "Android Field" to "center"
Description:
Use the <textAlign> property to change the horizontal text alignment of the
field widget.
*/
property textAlign get GetHorizontalTextAlign set SetHorizontalTextAlign
metadata textAlign.default is "left"
/**
Syntax:
set the verticalTextAlign of <widget> to <pAlign>
get the verticalTextAlign of <widget>
Summary: The vertical text alignment of the field widget.
Value (enum):
- "top": Top-aligned text
- "middle": Middle-aligned text
- "bottom": Bottom-aligned text
Example:
set the verticalTextAlign of widget "Android Field" to "middle"
Description:
Use the <textAlign> property to change the vertical text alignment of the
field widget.
*/
property verticalTextAlign get GetVerticalTextAlign set SetVerticalTextAlign
metadata verticalTextAlign.options is "top,middle,bottom"
metadata verticalTextAlign.editor is "com.livecode.pi.enum"
metadata verticalTextAlign.section is "Text"
metadata verticalTextAlign.label is "Vertical text align"
metadata verticalTextAlign.default is "top"
/**
Syntax:
set the autoCapitalizationType of <widget> to <pType>
get the autoCapitalizationType of <widget>
Summary: The auto-capitalization behavior of the field widget.
Value (enum):
- "none": the shift-key is never automatically enabled
- "words": the shift-key is enabled at the start of words
- "sentences": the shift-key is enabled at the start of sentences
- "all characters": the shift-key is enabled at the start of each character
Example:
set the autoCapitalizationType of widget "Android Field" to "sentences"
Description:
Use the <autoCapitalizationType> property to determine when the shift-key is
automatically enabled when typing.
*/
property autoCapitalizationType get GetAutoCapitalizationType set SetAutoCapitalizationType
metadata autoCapitalizationType.editor is "com.livecode.pi.enum"
metadata autoCapitalizationType.options is "none,words,sentences,all characters"
metadata autoCapitalizationType.default is "none"
metadata autoCapitalizationType.label is "Auto capitalization type"
/**
Syntax:
set the autoCorrectionType of <widget> to <pType>
get the autoCorrectionType of <widget>
Summary: The auto-correction behavior of the field widget.
Value (enum):
- "default": use the appropriate auto-correct behavior for the current script system
- "no": disable auto-correct behavior
- "yes": enable auto-correct behavior
Example:
set the autoCorrectionType of widget "Android Field" to "no"
Description:
Use the <autoCorrectionType> property to determine whether auto-correct behavior
should be enabled.
*/
property autoCorrectionType get GetAutoCorrectionType set SetAutoCorrectionType
metadata autoCorrectionType.editor is "com.livecode.pi.enum"
metadata autoCorrectionType.options is "default,no,yes"
metadata autoCorrectionType.default is "default"
metadata autoCorrectionType.label is "Auto correction type"
/**
Syntax:
set the keyboardType of <widget> to <pType>
get the keyboardType of <widget>
Summary: The type of keyboard associated to the field widget.
Value (enum):
- "default": the default keyboard
- "alphabet": the alphabetic keyboard
- "numeric": the numeric keyboard with punctuation
- "URL": the URL entry keyboard
- "number": the number pad keyboard
- "phone": the phone number pad keyboard
- "contact": the phone contact pad keyboard
- "email": the email keyboard
- "decimal": the decimal numeric pad keyboard
Example:
set the keyboardType of widget "Android Field" to "URL"
Description:
Use the <keyboardType> property to determine what kind of keyboard should be
displayed when this field widget is focused.
*/
property keyboardType get GetKeyboardType set SetKeyboardType
metadata keyboardType.editor is "com.livecode.pi.enum"
metadata keyboardType.options is "default,alphabet,numeric,URL,number,phone,contact,email,decimal"
metadata keyboardType.label is "Keyboard type"
/**
Syntax:
set the returnKeyType of <widget> to <pType>
get the returnKeyType of <widget>
Summary: The type of action assigned to the return key on the keyboard
associated with this field widget.
Value (enum):
- "default": the normal return key action
- "none": no return key action
- "go": take the user to the target of the text they typed
- "next": move to the next field that will accept text
- "previous": move to the previous field that will accept text
- "search": take the user to the results of searching for the text they have typed
- "send": deliver the text to its target
- "done": close IME
Example:
set the returnKeyType of widget "Android Field" to "previous"
Description:
Use the <returnKeyType> property to determine what kind of action should be
performed when the return key on the keyboard associated with this field widget
is pressed.
*/
property returnKeyType get GetReturnKeyType set SetReturnKeyType
metadata returnKeyType.editor is "com.livecode.pi.enum"
metadata returnKeyType.options is "default,none,go,search,send,next,done,previous"
metadata returnKeyType.default is "default"
metadata returnKeyType.label is "Return key type"
/**
Syntax:
set the contentType of <widget> to <pType>
get the contentType of <widget>
Summary: What kind of content the field contains.
Value (enum):
- "plain": plain, unstyled text
- "password": plain text displayed in the standard password style
Example:
set the contentType of widget "Android Field" to "password"
Description:
Use the <contentType> property to determine what kind of content the control
contains.
*/
property contentType get GetContentType set SetContentType
metadata contentType.editor is "com.livecode.pi.enum"
metadata contentType.options is "plain,password"
metadata contentType.default is "plain"
metadata contentType.label is "Content type"
/**
Syntax:
set the multiline of <widget> to {true | false}
get the multiline of <widget>
Summary: Whether the field can contain multiple lines or not.
Description:
Use the <multiline> property to allow or disallow the user to enter multiple
lines of text in the field.
*/
property multiline get GetMultiline set SetMultiline
metadata multiline.label is "Multi-line"
/**
Syntax:
set the editable of <widget> to {true | false}
get the editable of <widget>
Summary: Whether the field can be edited or not
Description:
Use the <editable> property to allow or disallow the user to enter text in the
field.
*/
property editable get GetEditable set SetEditable
metadata editable.label is "Editable"
/**
Syntax:
set the dataDetectorTypes of <widget> to <pType>
get the dataDetectorTypes of <widget>
Summary: What types of data should be clickable in the field.
Value (set):
- "phone number": Phone numbers should be clickable
- "link": Links should be clickable
- "email": Email addresses should be clickable
- "address": Addresses should be clickable
Example:
set the dataDetectorTypes of widget "Android Field" to "email,link"
Example:
set the dataDetectorTypes of widget "Android Field" to empty
Description:
Use the <dataDetectorTypes> property to determine what kind of data should be
detected and automatically converted to clikckable URLs.
*/
property dataDetectorTypes get GetDataDetectorTypes set SetDataDetectorTypes
metadata dataDetectorTypes.editor is "com.livecode.pi.set"
metadata dataDetectorTypes.options is "phone number,link,email,address"
metadata dataDetectorTypes.label is "Data detector types"
/**
Syntax:
set the scrollingEnabled of <widget> to {true | false}
get the scrollingEnabled of <widget>
Summary: Whether the field can be scrolled or not.
Description:
Use the <scrollingEnabled> property to allow or disallow the user to scroll the
field.
*/
property scrollingEnabled get GetScrollingEnabled set SetScrollingEnabled
metadata scrollingEnabled.label is "Scrolling enabled"
/**
Syntax:
set the passReturnKey of <widget> to {true|false}
get the passReturnKey of <widget>
Summary: Whether the return key adds a new line to the field
Example:
command createField
create widget as "com.livecode.widget.native.android.field"
set the passReturnKey of it to false
end createField
-- In the widget script
on returnKey
answer "You entered" && the text of the target
end returnKey
Description:
Use the <passReturnKey> property to control whether the
native keyboard return key adds a new line to the field or
not.
*/
property passReturnKey get mPassReturnKey set mPassReturnKey
metadata passReturnKey.label is "Return key adds new line"
metadata passReturnKey.default is "true"
// Non-persistent
/**
Syntax:
set the focused of <widget> to {true | false}
get the focused of <widget>
Summary: Whether the field is focused or not.
Description:
Use the <focused> property to request focus for the native field, or remove it.
*/
property focused get GetFocused set SetFocused
metadata focused.user_visible is "false"
/**
Syntax:
set the selectedRange of <widget> to <pRange>
get the selectedRange of <widget>
Summary: The range of text of the widget that is selected.
Value(string):
A comma-delimiter pair of the (1-based) start index and length.
Example:
-- Select the first 20 chars of the field widget
set the selectedRange of widget "Android Text" to "1,20"
Description:
Use the <selectedRange> property to determine the start index and the length of
the text that is to appear as selected.
*/
property selectedRange get GetSelectedRange set SetSelectedRange
metadata selectedRange.user_visible is "false"
private handler IsAndroid() returns Boolean
return the operating system is "android"
end handler
// Store all persistent properties in OnSave
public handler OnSave(out rProperties as Array)
put mText into rProperties["Text"]
put mTextColor into rProperties["TextColor"]
put mTextAlign into rProperties["TextAlign"]
put mVerticalTextAlign into rProperties["VerticalTextAlign"]
put mAutoCapitalizationType into rProperties["AutoCapitalizationType"]
put mAutoCorrectionType into rProperties["AutoCorrectionType"]
put mKeyboardType into rProperties["KeyboardType"]
put mReturnKeyType into rProperties["ReturnKeyType"]
put mContentType into rProperties["ContentType"]
put mDataDetectorTypes into rProperties["DataDetectorTypes"]
put mMultiline into rProperties["Multiline"]
put mEditable into rProperties["Editable"]
put mScrollingEnabled into rProperties["ScrollingEnabled"]
put mPassReturnKey into rProperties["PassReturnKey"]
end handler
// Set all persistent properties in OnLoad
public handler OnLoad(in pProperties as Array)
put pProperties["Text"] into mText
put pProperties["TextColor"] into mTextColor
put pProperties["TextAlign"] into mTextAlign
put pProperties["VerticalTextAlign"] into mVerticalTextAlign
put pProperties["AutoCapitalizationType"] into mAutoCapitalizationType
put pProperties["AutoCorrectionType"] into mAutoCorrectionType
put pProperties["KeyboardType"] into mKeyboardType
put pProperties["ReturnKeyType"] into mReturnKeyType
put pProperties["ContentType"] into mContentType
put pProperties["DataDetectorTypes"] into mDataDetectorTypes
put pProperties["Multiline"] into mMultiline
put pProperties["Editable"] into mEditable
put pProperties["ScrollingEnabled"] into mScrollingEnabled
put pProperties["PassReturnKey"] into mPassReturnKey
end handler
// Set up all the default values for properties in constants
constant kDefaultHorizontalTextAlign is "left"
constant kDefaultVerticalTextAlign is "top"
constant kDefaultTextColor is "0,0,0,255"
constant kDefaultAutoCapitalizationType is "none"
constant kDefaultAutoCorrectionType is "default"
constant kDefaultKeyboardType is "default"
constant kDefaultContentType is "plain"
constant kDefaultDataDetectorTypes is ""
constant kDefaultReturnKeyType is "default"
// When creating the widget, set all instance variables to the pre-defined
// default values.
public handler OnCreate()
put kDefaultHorizontalTextAlign into mTextAlign
put kDefaultVerticalTextAlign into mVerticalTextAlign
put "" into mText
put kDefaultTextColor into mTextColor
put kDefaultAutoCapitalizationType into mAutoCapitalizationType
put kDefaultAutoCorrectionType into mAutoCorrectionType
put kDefaultKeyboardType into mKeyboardType
put kDefaultContentType into mContentType
put kDefaultDataDetectorTypes into mDataDetectorTypes
put kDefaultReturnKeyType into mReturnKeyType
put true into mMultiline
put true into mEditable
put true into mScrollingEnabled
put true into mPassReturnKey
end handler
// Constants pulled from the android.content.Context class
constant INPUT_METHOD_SERVICE is "input_method"
private handler InitView()
// Create an android button using the Engine Context
variable tContext as JObject
put ApplicationContext() into tContext
put _JNI_CreateView(tContext) into mNativeObj
// get the pointer from the view and set the native layer
variable tPointer as Pointer
put PointerFromJObject(mNativeObj) into tPointer
set my native layer to tPointer
// Now we have created the native View, add the event listeners so we can
// send the appropriate messages, and apply all the properties.
SetListeners()
ApplyProperties()
// Retrieve a reference to the Input Method Manager
variable tServiceName as JString
put StringToJString(INPUT_METHOD_SERVICE) into tServiceName
put _JNI_GetSystemService(tContext, tServiceName) into mIMMObj
end handler
// Destroy the native layer
private handler FinalizeView()
set my native layer to nothing
put nothing into mNativeObj
end handler
// If we are on android, create the native view when the parent card opens
public handler OnOpen()
if IsAndroid() then
InitView()
end if
end handler
// If we are on android, destroy the native view when the parent card closes
public handler OnClose()
if IsAndroid() then
FinalizeView()
end if
end handler
handler ApplyProperties()
SetHorizontalTextAlign(mTextAlign)
SetVerticalTextAlign(mVerticalTextAlign)
SetText(mText)
SetTextColor(mTextColor)
SetAutoCapitalizationType(mAutoCapitalizationType)
SetAutoCorrectionType(mAutoCorrectionType)
SetKeyboardType(mKeyboardType)
SetContentType(mContentType)
SetDataDetectorTypes(mDataDetectorTypes)
SetMultiline(mMultiline)
SetEditable(mEditable)
SetScrollingEnabled(mScrollingEnabled)
SetParentProperties()
end handler
// If any of the general object properties is changed, we get this message. So
// ensure that the native view is updated with these values, if we are on
// android and the view is open
public handler OnParentPropertyChanged()
if mNativeObj is not nothing then
SetParentProperties()
end if
end handler
handler SetParentProperties()
SetEnabled(my enabled)
SetTextSize(the size of my font)
SetTypeface(my font)
end handler
// Constants pulled from the android.view.inputmethod.InputMethodManager class
constant INPUT_SHOW_IMPLICIT is 1
constant INPUT_SHOW_FORCED is 2
// Constants pulled from the android.text.InputType class
constant TYPE_CLASS_DATETIME is 4
constant TYPE_CLASS_NUMBER is 2
constant TYPE_CLASS_PHONE is 3
constant TYPE_CLASS_TEXT is 1
constant TYPE_DATETIME_VARIATION_DATE is 16
constant TYPE_DATETIME_VARIATION_NORMAL is 0
constant TYPE_DATETIME_VARIATION_TIME is 32
constant TYPE_MASK_CLASS is 15
constant TYPE_MASK_FLAGS is 16773120
constant TYPE_MASK_VARIATION is 4080
constant TYPE_NULL is 0
constant TYPE_NUMBER_FLAG_DECIMAL is 8192
constant TYPE_NUMBER_FLAG_SIGNED is 4096
constant TYPE_NUMBER_VARIATION_NORMAL is 0
constant TYPE_NUMBER_VARIATION_PASSWORD is 16
constant TYPE_TEXT_FLAG_AUTO_COMPLETE is 65536
constant TYPE_TEXT_FLAG_AUTO_CORRECT is 32768
constant kAutoCapitalizationTypes is { \
"none":0, \
"words": 8192, \
"sentences": 16384, \
"all characters": 4096 \
}
constant TYPE_TEXT_FLAG_CAP_CHARACTERS is 4096
constant TYPE_TEXT_FLAG_CAP_SENTENCES is 16384
constant TYPE_TEXT_FLAG_CAP_WORDS is 8192
constant TYPE_TEXT_FLAG_IME_MULTI_LINE is 262144
constant TYPE_TEXT_FLAG_MULTI_LINE is 131072
constant TYPE_TEXT_FLAG_NO_SUGGESTIONS is 524288
constant TYPE_TEXT_VARIATION_EMAIL_ADDRESS is 32
constant TYPE_TEXT_VARIATION_EMAIL_SUBJECT is 48
constant TYPE_TEXT_VARIATION_FILTER is 176
constant TYPE_TEXT_VARIATION_LONG_MESSAGE is 80
constant TYPE_TEXT_VARIATION_NORMAL is 0
constant TYPE_TEXT_VARIATION_PASSWORD is 128
constant TYPE_TEXT_VARIATION_PERSON_NAME is 96
constant TYPE_TEXT_VARIATION_PHONETIC is 192
constant TYPE_TEXT_VARIATION_POSTAL_ADDRESS is 112
constant TYPE_TEXT_VARIATION_SHORT_MESSAGE is 64
constant TYPE_TEXT_VARIATION_URI is 16
constant TYPE_TEXT_VARIATION_VISIBLE_PASSWORD is 144
constant TYPE_TEXT_VARIATION_WEB_EDIT_TEXT is 160
constant TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS is 208
constant TYPE_TEXT_VARIATION_WEB_PASSWORD is 224
constant kKeyboardTypes is [ \
"default","alphabet","numeric","URL","number","phone","contact","email","decimal" \
]
// Helper to convert a keyboard type to the appropriate InputType value
handler KeyboardTypeToEnum(in pType as String) returns Integer
variable tBits as List
if pType is "alphabet" or pType is "default" then
put [TYPE_CLASS_TEXT] into tBits
else if pType is "numeric" or pType is "decimal" then
put [TYPE_CLASS_NUMBER, TYPE_NUMBER_FLAG_SIGNED, \
TYPE_NUMBER_FLAG_DECIMAL] into tBits
else if the lower of pType is "url" then
put [TYPE_CLASS_TEXT, TYPE_TEXT_VARIATION_URI] into tBits
else if pType is "number" then
put [TYPE_CLASS_NUMBER] into tBits
else if pType is "phone" then
put [TYPE_CLASS_PHONE] into tBits
else if pType is "contact" then
put [TYPE_CLASS_TEXT, TYPE_TEXT_VARIATION_PERSON_NAME] \
into tBits
else if pType is "email" then
put [TYPE_CLASS_TEXT, TYPE_TEXT_VARIATION_EMAIL_ADDRESS] \
into tBits
else
throw "invalid keyboard type" && pType
end if
return BitwiseOrList(tBits)
end handler
handler EnumToKeyboardType(in pEnum as Integer)
variable tType as String
repeat for each element tType in kKeyboardTypes
if KeyboardTypeToEnum(tType) is pEnum then
return tType
end if
end repeat
return "default"
end handler
__safe foreign handler _JNI_PasswordTransformationMethod_getInstance() returns JObject \
binds to "java:android.text.method.PasswordTransformationMethod>getInstance()Landroid/text/method/PasswordTransformationMethod;!static"
handler PasswordTransformationMethod_getInstance() returns JObject
variable tJNIResult as JObject
put _JNI_PasswordTransformationMethod_getInstance() into tJNIResult
return tJNIResult
end handler
handler type FocusChangeCallback(in pView as JObject, in pHasFocus as JObject)
__safe foreign handler _JNI_View_OnFocusChangeListener(in pHandler as FocusChangeCallback) returns JObject \
binds to "java:android.view.View$OnFocusChangeListener>interface()"
__safe foreign handler _JNI_View_setOnFocusChangeListener(in pObj as JObject, in pParam_listener as JObject) returns nothing \
binds to "java:android.view.View>setOnFocusChangeListener(Landroid/view/View$OnFocusChangeListener;)V?ui"
__safe foreign handler _JNI_View_isEnabled(in pObj as JObject) returns JBoolean \
binds to "java:android.view.View>isEnabled()Z?ui"
__safe foreign handler _JNI_View_isFocusable(in pObj as JObject) returns JBoolean \
binds to "java:android.view.View>isFocusable()Z?ui"
__safe foreign handler _JNI_View_setFocusable(in pObj as JObject, in pParam_focusable as JBoolean) returns nothing \
binds to "java:android.view.View>setFocusable(Z)V?ui"
__safe foreign handler _JNI_View_clearFocus(in pObj as JObject) returns nothing \
binds to "java:android.view.View>clearFocus()V?ui"
__safe foreign handler _JNI_View_requestFocus(in pObj as JObject) returns JBoolean \
binds to "java:android.view.View>requestFocus()Z?ui"
__safe foreign handler _JNI_View_isFocused(in pObj as JObject) returns JBoolean \
binds to "java:android.view.View>isFocused()Z?ui"
__safe foreign handler _JNI_InputMethod_showSoftInput(in pIMMObj as JObject, in pViewObj as JObject, in pFlags as JInt) returns JBoolean \
binds to "java:android.view.inputmethod.InputMethodManager>showSoftInput(Landroid/view/View;I)Z"
handler View_setOnFocusChangeListener(in pObj as JObject, in pParam_listener as JObject) returns nothing
_JNI_View_setOnFocusChangeListener(pObj, pParam_listener)
end handler
handler View_isEnabled(in pObj as JObject) returns Boolean
variable tJNIResult as Boolean
put _JNI_View_isEnabled(pObj) into tJNIResult
return tJNIResult
end handler
handler View_isFocusable(in pObj as JObject) returns Boolean
variable tJNIResult as Boolean
put _JNI_View_isFocusable(pObj) into tJNIResult
return tJNIResult
end handler
handler View_setFocusable(in pObj as JObject, in pParam_focusable as Boolean) returns nothing
_JNI_View_setFocusable(pObj, pParam_focusable)
end handler
public handler View_clearFocus(in pObj as JObject) returns nothing
_JNI_View_clearFocus(pObj)
end handler
public handler View_requestFocus(in pObj as JObject) returns Boolean
variable tJNIResult as Boolean
put _JNI_View_requestFocus(pObj) into tJNIResult
return tJNIResult
end handler
public handler View_isFocused(in pObj as JObject) returns Boolean
variable tJNIResult as Boolean
put _JNI_View_isFocused(pObj) into tJNIResult
return tJNIResult
end handler
__safe foreign handler _JNI_TextWatcher_TextChangedListener(in pCallbacks as Array) returns JObject \
binds to "java:android.text.TextWatcher>interface()"
__safe foreign handler _JNI_TextView_addTextChangedListener(in pObj as JObject, in pParam_watcher as JObject) returns nothing \
binds to "java:android.widget.TextView>addTextChangedListener(Landroid/text/TextWatcher;)V?ui"
handler type EditorActionCallback(in pView as JObject, in pActionId as JObject, in pKeyEvent as optional JObject) returns JObject
__safe foreign handler _JNI_View_OnEditorActionListener(in pHandler as EditorActionCallback) returns JObject \
binds to "java:android.widget.TextView$OnEditorActionListener>interface()"
__safe foreign handler _JNI_TextView_setOnEditorActionListener(in pObj as JObject, in pParam_listener as JObject) returns nothing \
binds to "java:android.widget.TextView>setOnEditorActionListener(Landroid/widget/TextView$OnEditorActionListener;)V?ui"
__safe foreign handler _JNI_TextView_append(in pObj as JObject, in pParam_text as JString) returns nothing \
binds to "java:android.widget.TextView>append(Ljava/lang/CharSequence;)V?ui"
__safe foreign handler _JNI_TextView_appendAt(in pObj as JObject, in pParam_text as JString, in pParam_startIndex as JInt, in pParam_endIndex as JInt) returns nothing \
binds to "java:android.widget.TextView>append(Ljava/lang/CharSequence;II)V?ui"
__safe foreign handler _JNI_TextView_getAutoLinkMask(in pObj as JObject) returns JInt \
binds to "java:android.widget.TextView>getAutoLinkMask()I?ui"
__safe foreign handler _JNI_TextView_getGravity(in pObj as JObject) returns JInt \
binds to "java:android.widget.TextView>getGravity()I?ui"
__safe foreign handler _JNI_TextView_getImeOptions(in pObj as JObject) returns JInt \
binds to "java:android.widget.TextView>getImeOptions()I?ui"
__safe foreign handler _JNI_TextView_getInputType(in pObj as JObject) returns JInt \
binds to "java:android.widget.TextView>getInputType()I?ui"
__safe foreign handler _JNI_TextView_getMovementMethod(in pObj as JObject) returns optional JObject \
binds to "java:android.widget.TextView>getMovementMethod()Landroid/text/method/MovementMethod;?ui"
__safe foreign handler _JNI_TextView_getSelectionStart(in pObj as JObject) returns JInt \
binds to "java:android.widget.TextView>getSelectionStart()I?ui"
__safe foreign handler _JNI_TextView_getSelectionEnd(in pObj as JObject) returns JInt \
binds to "java:android.widget.TextView>getSelectionEnd()I?ui"
__safe foreign handler _JNI_TextView_getText(in pObj as JObject) returns JString \
binds to "java:android.widget.TextView>getText()Ljava/lang/CharSequence;?ui"
__safe foreign handler _JNI_TextView_getTextSize(in pObj as JObject) returns JFloat \
binds to "java:android.widget.TextView>getTextSize()F?ui"
__safe foreign handler _JNI_TextView_getTransformationMethod(in pObj as JObject) returns optional JObject \
binds to "java:android.widget.TextView>getTransformationMethod()Landroid/text/method/TransformationMethod;?ui"
__safe foreign handler _JNI_TextView_setAutoLinkMask(in pObj as JObject, in pParam_mask as JInt) returns nothing \
binds to "java:android.widget.TextView>setAutoLinkMask(I)V?ui"
__safe foreign handler _JNI_TextView_setEnabled(in pObj as JObject, in pParam_enabled as JBoolean) returns nothing \
binds to "java:android.widget.TextView>setEnabled(Z)V?ui"
__safe foreign handler _JNI_TextView_setGravity(in pObj as JObject, in pParam_gravity as JInt) returns nothing \
binds to "java:android.widget.TextView>setGravity(I)V?ui"
__safe foreign handler _JNI_TextView_setImeOptions(in pObj as JObject, in pParam_options as JInt) returns nothing \
binds to "java:android.widget.TextView>setImeOptions(I)V?ui"
__safe foreign handler _JNI_TextView_setInputType(in pObj as JObject, in pParam_type as JInt) returns nothing \
binds to "java:android.widget.TextView>setInputType(I)V?ui"
__safe foreign handler _JNI_TextView_setMovementMethod(in pObj as JObject, in pParam_movement as optional JObject) returns nothing \
binds to "java:android.widget.TextView>setMovementMethod(Landroid/text/method/MovementMethod;)V?ui"
__safe foreign handler _JNI_TextView_setText(in pObj as JObject, in pParam_text as JString) returns nothing \
binds to "java:android.widget.TextView>setText(Ljava/lang/CharSequence;)V?ui"
__safe foreign handler _JNI_TextView_setTextColor(in pView as JObject, in pValue as JInt) returns nothing \
binds to "java:android.widget.TextView>setTextColor(I)V?ui"
__safe foreign handler _JNI_TextView_setTextSize(in pObj as JObject, in pParam_unit as JInt, in pParam_size as JFloat) returns nothing \
binds to "java:android.widget.TextView>setTextSize(IF)V?ui"
__safe foreign handler _JNI_TextView_setTypeface(in pView as JObject, in pValue as JObject) returns nothing \
binds to "java:android.widget.TextView>setTypeface(Landroid/graphics/Typeface;)V?ui"
__safe foreign handler _JNI_TextView_setTransformationMethod(in pObj as JObject, in pParam_mthd as optional JObject) returns nothing \
binds to "java:android.widget.TextView>setTransformationMethod(Landroid/text/method/TransformationMethod;)V?ui"
handler TextView_addTextChangedListener(in pObj as JObject, in pParam_watcher as JObject) returns nothing
_JNI_TextView_addTextChangedListener(pObj, pParam_watcher)
end handler
handler TextView_setOnEditorActionListener(in pObj as JObject, in pParam_listener as JObject) returns nothing
_JNI_TextView_setOnEditorActionListener(pObj, pParam_listener)
end handler
handler TextView_append(in pObj as JObject, in pParam_text as String) returns nothing
variable tParam_text as JString
put StringToJString(pParam_text) into tParam_text
_JNI_TextView_append(pObj, tParam_text)
end handler
handler TextView_appendAt(in pObj as JObject, in pParam_text as String, in pParam_startIndex as Number, in pParam_endIndex as Number) returns nothing
variable tParam_text as JString
put StringToJString(pParam_text) into tParam_text
_JNI_TextView_appendAt(pObj, tParam_text, pParam_startIndex, pParam_endIndex)
end handler
handler TextView_getAutoLinkMask(in pObj as JObject) returns Number
variable tJNIResult as Number
put _JNI_TextView_getAutoLinkMask(pObj) into tJNIResult
return tJNIResult
end handler
handler TextView_getGravity(in pObj as JObject) returns Number
variable tJNIResult as Number
put _JNI_TextView_getGravity(pObj) into tJNIResult
return tJNIResult
end handler
handler TextView_getImeOptions(in pObj as JObject) returns Number
variable tJNIResult as Number
put _JNI_TextView_getImeOptions(pObj) into tJNIResult
return tJNIResult
end handler
handler TextView_getInputType(in pObj as JObject) returns Number
variable tJNIResult as Number
put _JNI_TextView_getInputType(pObj) into tJNIResult
return tJNIResult
end handler
handler TextView_getMovementMethod(in pObj as JObject) returns optional JObject
variable tJNIResult as optional JObject
put _JNI_TextView_getMovementMethod(pObj) into tJNIResult
return tJNIResult
end handler
handler TextView_getSelectionStart(in pObj as JObject) returns Number
variable tJNIResult as Number
put _JNI_TextView_getSelectionStart(pObj) into tJNIResult
return tJNIResult
end handler
handler TextView_getSelectionEnd(in pObj as JObject) returns Number
variable tJNIResult as Number
put _JNI_TextView_getSelectionEnd(pObj) into tJNIResult
return tJNIResult
end handler
__safe foreign handler _JNI_CharSequence_toString(in pObj as JObject) returns JString \
binds to "java:java.lang.CharSequence>toString()Ljava/lang/String;"
handler TextView_getText(in pObj as JObject) returns String
variable tJNIResult as JObject
put _JNI_TextView_getText(pObj) into tJNIResult
variable tString as JString
put _JNI_CharSequence_toString(tJNIResult) into tString
return StringFromJString(tString)
end handler
handler TextView_getTextSize(in pObj as JObject) returns Number
variable tJNIResult as Number
put _JNI_TextView_getTextSize(pObj) into tJNIResult
return tJNIResult
end handler
handler TextView_getTransformationMethod(in pObj as JObject) returns optional JObject
variable tJNIResult as optional JObject
put _JNI_TextView_getTransformationMethod(pObj) into tJNIResult
return tJNIResult
end handler
handler TextView_setAutoLinkMask(in pObj as JObject, in pParam_mask) returns nothing
_JNI_TextView_setAutoLinkMask(pObj, pParam_mask)
end handler
handler TextView_setEnabled(in pObj as JObject, in pParam_enabled as Boolean) returns nothing
_JNI_TextView_setEnabled(pObj, pParam_enabled)