-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextFormatter.bas
More file actions
45 lines (41 loc) · 1.58 KB
/
TextFormatter.bas
File metadata and controls
45 lines (41 loc) · 1.58 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
Type=Class
Version=4.7
ModulesStructureVersion=1
B4J=true
@EndOfDesignText@
#Event: TextValidator(Change As JavaObject) As JavaObject
Sub Class_Globals
Private fx As JFX
Private mModule As Object
Private mEventName As String
Private mTextInput As JavaObject
End Sub
'Initializes the object.
'Module : the calling Module
'EventName : The callback sub prefix, you can use the same callback on multiple fields
'TextInput: Either a TextField or a TextArea
Public Sub Initialize(Module As Object,EventName As String,TextInput As JavaObject)
mModule = Module
mEventName = EventName
mTextInput = TextInput
If SubExists(mModule,mEventName & "_TextValidator") Then mTextInput.RunMethod("setTextFormatter",Array(GetTextFormatter))
End Sub
'Returns a new TextFormatter object and creates the callback sub
Private Sub GetTextFormatter As JavaObject
Dim TextFormatter1 As JavaObject
Dim Filter As Object = AsJO(mTextInput).CreateEvent("java.util.function.UnaryOperator","TextFilter",Null) 'ignore
TextFormatter1.InitializeNewInstance("javafx.scene.control.TextFormatter",Array(Filter))
Return TextFormatter1
End Sub
'Wrapper for the callback sub, calls Eventname_TextValidator sub in the calling module.
Private Sub TextFilter_Event(MethodName As String,Args() As Object) As Object
Dim Change As TFChange
Change.SetObject(Args(0))
If Change.isContentChange = False Then Return Change.GetObject
Change = CallSub2(mModule,mEventName & "_TextValidator",Change)
If Change = Null Then Return Null
Return Change.GetObject
End Sub
Private Sub AsJO(JO As JavaObject) As JavaObject
Return JO
End Sub