B4J Question cursor after mouse over

tufanv

Expert
Licensed User
Longtime User
Hello

I want to show hand as cursor when user is on label , I can do that with :

B4X:
Sub lblweb_MouseMoved (EventData As MouseEvent)
    MainForm.RootPane.MouseCursor=fx.Cursors.HAND
End Sub

How can I change to default when mouse exit . ?

Thanks
 

stevel05

Expert
Licensed User
Longtime User
You can set the MouseEntered and Exited eventhandlers using JavaObject:
B4X:
    Dim JO As JavaObject = lblWeb 'or Whichever Node you are tracking
    Dim O As Object = JO.CreateEventFromUI("javafx.event.EventHandler","MouseEntered",Null)
    JO.RunMethod("setOnMouseEntered",Array(O))
    Dim O As Object = JO.CreateEventFromUI("javafx.event.EventHandler","MouseExited",Null)
    JO.RunMethod("setOnMouseExited",Array(O))

Then

B4X:
Private Sub MouseEntered_Event (MethodName As String, Args() As Object)
  'Show the Hand cursor
 
End Sub

Private Sub MouseExited_Event (MethodName As String, Args() As Object)
'Show the default cursor
End Sub
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
You can set the MouseEntered and Exited eventhandlers using JavaObject:
B4X:
    Dim JO As JavaObject = lblWeb 'or Whichever Node you are tracking
    Dim O As Object = JO.CreateEventFromUI("javafx.event.EventHandler","MouseEntered",Null)
    JO.RunMethod("setOnMouseEntered",Array(O))
    Dim O As Object = JO.CreateEventFromUI("javafx.event.EventHandler","MouseExited",Null)
    JO.RunMethod("setOnMouseExited",Array(O))

Then

B4X:
Private Sub MouseEntered_Event (MethodName As String, Args() As Object)
  'Show the Hand cursor

End Sub

Private Sub MouseExited_Event (MethodName As String, Args() As Object)
'Show the default cursor
End Sub

Works Perfect ! Thank you
 
Upvote 0

Carlos marin

Active Member
Licensed User
Longtime User
Mas sencillo aun:

Cursor Hand:
Sub label_MouseEntered (EventData As MouseEvent)
    label.MouseCursor = fx.Cursors.HAND
End Sub
 
Upvote 0
Top