Double click on RadRibbonView causes minimize with minimization enabled

1 Answer 48 Views
RibbonView and RibbonWindow
Damian
Top achievements
Rank 1
Damian asked on 13 Apr 2023, 02:45 PM

Hi 

Current scenario I am trying to fix is we are wanting to make use of the minimization feature, but disable the double click toggling the minimization. Limiting the minimization toggle to only the Minimize button (or a custom context menu). 

I have tried using the PreviewMouseDoubleClick event which works at a first glance, however it ends up being that a triple click will now minimize. 
Other less successful attempts are disabling minimization and only enable it before the ribbon would be minimized or un minimized. This would mean more control over when the ribbon is minimized but would require more effort in getting all aspects of the minimization working. 

Any assistance would be appreciated. It doesnt feel like too complicated of a problem but struggling with it none the less 

1 Answer, 1 is accepted

Sort by
1
Accepted
Martin Ivanov
Telerik team
answered on 18 Apr 2023, 12:44 PM

Hello Damian,

The triple click doesn't work because the ribbonview doesn't rely on the MouseDoubleClick event. Instead, it uses the MouseLeftButtonDown event with a timer that checks the time between two clicks (500ms). To disable the minimization on tab click, you can use this information along with the PreviewMouseLeftButtonDown event of the RadRibbonTabs.

private long lastTicks;
private void RadRibbonTab_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
	bool doubleClick = false;
	var nowTicks = DateTime.Now.Ticks;
	if (nowTicks - this.lastTicks < 5000000)
	{
		doubleClick = true;
	}
	this.lastTicks = nowTicks;

	if (doubleClick)
	{

		e.Handled = true;
	}
}

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.

Luke
Top achievements
Rank 1
commented on 20 Apr 2023, 07:52 PM | edited

Hi Martin,

Thanks for the reply, that does help but it has some side effects:

  • You can no longer click between RadRibbonTab in under 500ms via single click. 
  • You can no longer click on a RadRibbonTab and then click on a RadRibbonButton in under 500ms via a single click.

If you continue clicking under 500ms you can get stuck in a loop where you can't click on anything until you wait over 500ms again.

We would really love a way to disable all this enforced logic about clicking to minimise so we can leave the rest of the ribbon unaffected. The reason for us wanting to do this is some of our customers have ended up minimizing the ribbon by accident - it's quite easy to do with this odd 500ms wait detection that's included, i'm not sure that's a standard thing I've seen before in click events.

Martin Ivanov
Telerik team
commented on 21 Apr 2023, 06:13 AM

It turns out that I've missed to include several important cases in the code. The first one is that this event should be attached to the RadRibbonTab's not the RadRibbonView. The other is that the code should take into account the current selection state of the tab and also if actually a RadRibbonTab is clicked and not its contents (like a button). 

Here is the updated version of the code:

private long lastTicks;
private void RadRibbonTab_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
	var clickedElement = (FrameworkElement)e.OriginalSource;
	var isTabClick = clickedElement.ParentOfType<RadRibbonTab>() != null;

	if (!isTabClick) return;

	var tab = (RadRibbonTab)sender;
	bool doubleClick = false;
	var nowTicks = DateTime.Now.Ticks;
	if (nowTicks - this.lastTicks < 5000000)
	{
		if (this.ribbonView.IsMinimized || tab.IsSelected)
		{
			doubleClick = true;
		}            
	}
	this.lastTicks = nowTicks;

	if (doubleClick)
	{
	   e.Handled = true;
	}
}

The 500ms is the default delay between two consecutive clicks that can be considered a double click in Windows OS. 

Luke
Top achievements
Rank 1
commented on 21 Apr 2023, 08:00 AM

We will give this a go Martin! Many thanks :) 

Appreciate the quick response :)

Luke
Top achievements
Rank 1
commented on 21 Apr 2023, 12:16 PM

This worked for us. Thanks again Martin! 
Tags
RibbonView and RibbonWindow
Asked by
Damian
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or