#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private TextArea1 As TextArea
Private Button1 As Button
Private CTRL_V As JavaObject
Private COMMAND_V As JavaObject
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub Button1_Click
TextArea1.RequestFocus
CTRL_V = asJOKeyPressPaste(Me).RunMethod("keyPressedEventCTRL_V",Null)
COMMAND_V = asJOKeyPressPaste(Me).RunMethod("keyPressedEventCOMMAND_V",Null)
'Log(CTRL_V)
AutoPaste_CTRL_V
End Sub
Sub asJOKeyPressPaste(o As JavaObject) As JavaObject
Return o
End Sub
' PAY ATTENTION TO THIS LINE NULL WON'T WORK!!!
Sub AutoPaste_CTRL_V
CTRL_V.RunMethod("fireEvent",Array(Null,CTRL_V))
End Sub
Sub AutoPaste_COMMAND_V
COMMAND_V.RunMethod("fireEvent",Array(TextArea1,COMMAND_V))
End Sub
#if java
import javafx.scene.input.*;
import javafx.event.Event;
// CTRL_V (windows CTRL+V)
public static KeyEvent keyPressedEventCTRL_V()
{
return new KeyEvent(KeyEvent.KEY_PRESSED,null,"V",KeyCode.V,false,true,false,false);
}
// COMMAND_V (Mac CMD+V)
public static KeyEvent keyPressedEventCOMMAND_V()
{
return new KeyEvent(KeyEvent.KEY_PRESSED,null,"V",KeyCode.V,false,false,false,true);
}
// breaks down as
// KeyEvent(EventType<KeyEvent> eventType, String character, String text, KeyCode code, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown)
#End If