B4J Question datePicker mouse click

atiaust

Active Member
Licensed User
Longtime User
Hi All,

I have a datePicker that I change externally by setting datePicker1.DateTicks = ticksValue
This in turn fires the datePicker1_valueChanged sub. which is fine.

How can I tell if a datePicker has been clicked on and changed?
There is no datePicker1_action or datePicker1_mouseClick etc.

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It will be easier to implement with the coming resumable subs feature:
B4X:
Sub SetDate(t As Long)
   If t = DatePicker1.DateTicks Then Return
   DatePicker1.DateTicks = t
   Wait For DatePicker1_ValueChanged (Value As Long)
   Log("event ignored")
End Sub

For now you will need to do something like:
B4X:
Sub SetDate(t As Long)
   If t = DatePicker1.DateTicks Then Return
   DatePicker1.DateTicks = t
  IgnoreNextDatePickerEvent = True
End Sub

Sub DatePicker1_ValueChanged (Value As Long)
   If IgnoreNextDatePickerEvent Then
     IgnoreNextDatePickerEvent  = False
     Return
   End If
  'handle event
End Sub
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
How can I tell if a datePicker has been clicked on and changed?
I think this is the way to know if the date was set by a user (clicked and validated), and probably what you need?:
B4X:
Sub Initialize
    Dim dp As JavaObject = DatePicker1
    Dim e As Object = dp.CreateEvent("javafx.event.EventHandler", "dp_OnAction", False)
    dp.RunMethod("setOnAction", Array(e))
End Sub

Private Sub dp_OnAction_Event(MethodName As String, Args() As Object)
    'your action 
End Sub
 
Upvote 0
Top