SelectedSlot is Null when ContextMenu in ScheduleView opened via touch

1 Answer 77 Views
ScheduleView
Vic
Top achievements
Rank 1
Iron
Vic asked on 20 Jul 2023, 11:59 PM

Hello,

I have a ScheduleView that uses only a MonthViewDefinition and implements a ContextMenu for copy/pasting appointments. It works great when using a mouse to right-click and open the context menu.  However, when opening the menu with a 'right-touch', the SelectedSlot property of the ScheduleView is always null.  As a result, the copy/paste only works with touch if the user first touches a slot to 'select' it and then opens the context menu. 

If the user 'right-touches' the day header (GoToDayButton) or an actual appointment, I am able to work around this problem by identifying the selected slot using GetClickedElement<TimeRulerMonthViewItem> or GetClickedElement<AppointmentItem> in the Opening event and programmatically setting the SelectedSlot property.  However, if they are 'right-touching' the empty area in a day slot, I don't see a way to identify the selected day, as GetClickedElement<HighlightItem> returns null.  Is there another way to identify the 'clicked' day in this case, or do you have any other suggestions on dealing with this touch bug?

Thanks in advance,

Vic

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 11 Aug 2023, 04:23 PM

Hello Vic,

By right click I guess you mean the touch-and-hold gesture. In any case, the slot highlighting happens on the tap gesture which is basically TouchDown+TouchUp. The tap gesture is not executed when you have touch-and-hold, which is why the slot is not highlighted. To achieve your requirement, you can use the TouchManager to subscribe to the TouchAndHold event and manually update the slot.

public MainWindow()
{
	InitializeComponent();
	TouchManager.AddTouchDownEventHandler(this.ScheduleView, OnScheduleViewTouchDown);
}

private void OnScheduleViewTouchDown(object sender, TouchEventArgs args)
{
	Point position = args.GetTouchPoint(this.ScheduleView).Position;
	var tryHighlightSlotMethod = typeof(ScheduleViewBase).GetMethod("TryHighlightSlot", BindingFlags.NonPublic | BindingFlags.Instance);
	tryHighlightSlotMethod.Invoke(this.ScheduleView, new object[] { position });
}       

I hope that helps.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Vic
Top achievements
Rank 1
Iron
commented on 12 Aug 2023, 09:44 PM

Martin,

That did indeed help. Thank you!

Kind regards,
Vic

Tags
ScheduleView
Asked by
Vic
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or