### Hyperlink MouseClicked

Example of handling a MouseClicked Event for a Hyperlink.
This explains the principle only, for detailed example:
See B4JHowTo ListView > Customized ListView Hyperlink.
Create the Hyperlink
The hyperlink is created as a JavaObject and added to the ListView Item as a Node.
'Node = Hyperlink
Dim joHL As JavaObject
'Create the instance with the URL visible
joHL.InitializeNewInstance("javafx.scene.control.Hyperlink", Array("http://mysite"))
joHL.RunMethod("setFont", Array(fx.DefaultFont(12)))
'Set the value of the listview line as id - this could be used to set the line as selected when clicking on the hyperlink
joHL.RunMethod("setId", Array("9"))
'Add a mouseclicked eventhandler which opens the URL in the default browers
Dim oHL As Object = joHL.CreateEvent("javafx.event.EventHandler","HyperLinkMouseClicked",False)
joHL.RunMethod("setOnMouseClicked",Array(oHL))
'Add the node to the anchorpane
ap.AddNode(joHL, 0, 25dip, lv.Width, 20dip)
...
Handle mouseclicked event on the hyperlink
'Get the text from the hyperlink node and open in the default browser
`Private Sub HyperlinkMouseClicked_Event(EventName As String,Args() As Object) As Object
Dim MEvent As Event = Args(0)
'Assign the argument, which is a JavaObject to a new JavaObject
Dim joHL As JavaObject = Args(0)
'To understand the makeup of the JavaObject = the mouseclicked event
'(MouseEvent) MouseEvent [source = Hyperlink[id=0, styleClass=hyperlink]'http://mysite', target = Text[text="http://mysite", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL_VERTICAL_CENTER, font=Font[name=System Regular, family=System, style=Regular, size=10.0], fontSmoothingType=LCD, underline, fill=0x333333ff], eventType = MOUSE_CLICKED, consumed = false, x = 54.0, y = 10.0, z = 0.0, button = PRIMARY, pickResult = PickResult [node = Text[text="http://mysite... Log(joHL)
'Get the hyperlinktext which is the url - look at previous JavaObject makeup target = Text
Log(joHL.RunMethodJO("getTarget", Null).RunMethod("getText", Null))
fx.ShowExternalDocument(joHL.RunMethodJO("getTarget", Null).RunMethod("getText", Null))
'This will give you the Id
Log(joHL.RunMethodJO("getSource", Null).RunMethod("getId", Null))
'Consume the event
MEvent.Consume
Return False
End Sub`

Changed: 2018-06-07 09:12, Category: Events, File: T6C191M1365.htm, ID: 1365