Open x-ji opened 2 weeks ago
Hi @x-ji,
We have analyzed your query and would like to inform you, that in SfCalendar, the onTap callback triggers whenever the calendar elements are tapped on view. You can get the tapped date, appointments, and element details when the tapped action is performed on the element available in the CalendarTapDetails, and the onLongPress callback triggers whenever the calendar elements are long-pressed on view. You can get the long-pressed date, appointments, and element details when the tapped action is performed on the element available in the CalendarLongPressDetails. So, you can use this callback to differentiate the tap and create a different event. We have shared a UG documentation for your reference below.
UG Links:
https://help.syncfusion.com/flutter/calendar/callbacks#calendar-tap-callback
https://help.syncfusion.com/flutter/calendar/callbacks#long-press-callback
Please let us know if you need any further assistance.
Regards,
Preethika Selvam.
Hi @PreethikaSelvam thanks for the response. I see that CalendarTapDetails
has the following properties:
appointments → List? The collection of appointments that return from the date.
date → DateTime? The date that return from the view.
hashCode → int The hash code for this object.
resource → CalendarResource? The resource associated with the calendar cell in timeline views.
runtimeType → Type A representation of the runtime type of the object.
targetElement → CalendarElement The element that return from the view.
None of which gives me the precise coordinates within the targetElement
this tap or long press took place, which is what I would like to make use of (so that I can distinguish whether the tap took place on the left half or right half of the element). On the web with HTML and Javascript, this is usually available for example within the onClick
event.
Does this make sense?
Hi @x-ji,
Your requirement can only be achieved by wrapping two GestureDetector widgets in Expanded within the Row in the monthCellBuilder. However, due to the interaction not being passed to the builders, we are unable to achieve it at this time. We have already logged feature request for it in our feedback portal. We will prioritize the features of every release based on demand and priority. So, this feature will be available in any of our upcoming releases. You can also track the status of the feature with the feedback below.
If you have any additional specifications or suggestions for this feature request, please feel free to leave them in the comments section of the feedback link. This will help us to understand how you would like to use it and how we can improve it.
Regards,
Preethika Selvam.
Thanks for the update @PreethikaSelvam . I'll keep an eye on it.
Use case
I would like to trigger different actions based on where exactly the user tapped on the calendar cell. For example, tapping on the left half of the cell should create a different type of event by default compared with tapping on the right half.
Proposal
With JS events I can get the exact coordinates where the click happened and e.g. compare it to the width of the whole calendar component to understand whether the click happened on the left part of the cell or the right part. I see that
CalendarTapDetails
's properties only contain thetargetElement
but not the