Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Mouse cursor plus sign overlay (Read 1816 times)
Joel D.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Location: Seattle
Joined: Feb 6th, 2017
Mouse cursor plus sign overlay
Feb 20th, 2020 at 6:57pm
Print Post  
Is there a way to get the standard plus sign (+) that shows up during a drag-and-drop operation (like with DragDropEffects.Copy) to show up when I press the [Ctrl] key while creating a new link?
« Last Edit: Feb 20th, 2020 at 9:40pm by Joel D. »  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Mouse cursor plus sign overlay
Reply #1 - Feb 21st, 2020 at 8:26am
Print Post  
Try this -

Code
Select All
diagram.KeyDown += (ss, ee) => UpdateCursor();
diagram.KeyUp += (ss, ee) => UpdateCursor();
diagram.MouseMove += (ss, ee) => UpdateCursor();

void UpdateCursor()
{
	bool drawingLink =
		diagram.Interaction != null &&
		diagram.Interaction.CurrentItem is DiagramLink;
	bool ctrlKey =
		(Keyboard.Modifiers & ModifierKeys.Control) != 0;

	diagram.OverrideCursor =
		drawingLink && ctrlKey ?
			System.Windows.Input.Cursors.Cross : null;

	if (diagram.OverrideCursor == null)
	{
		// force repaint the default Cursor before mouse moves
		diagram.OverrideCursor = diagram.OverrideCursor;
	}
} 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Joel D.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Location: Seattle
Joined: Feb 6th, 2017
Re: Mouse cursor plus sign overlay
Reply #2 - Feb 21st, 2020 at 10:08pm
Print Post  
Thanks.  The setting of diagram.OverrideCursor to diagram.OverrideCursor fixes the issue that I saw where it wouldn't switch back to the the main Cursor until a mouse move.

The problem with this method, though, is that even though OverrideCursor is being set to null, I'm losing my other Cursor changes, such as when drawing a selection, the No cursor is supposed to show unless the selection is over valid objects, or when drawing a link, now the Hand cursor always shows up instead of the No cursor when the Link is over blank space or if the LinkCreating event handler sets e.Cancel to true.  I can see with debug prints that the OverrideCursor is null, but the main Cursor doesn't seem to be changing to what the Diagram was previously telling it to.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: Mouse cursor plus sign overlay
Reply #3 - Feb 28th, 2020 at 4:31pm
Print Post  
Try this -
Code
Select All
void UpdateCursor()
{
	var baseCursor = diagram.Cursor;

	bool drawingLink =
		diagram.Interaction != null &&
		diagram.Interaction.CurrentItem is DiagramLink;
	bool ctrlKey =
		(Keyboard.Modifiers & ModifierKeys.Control) != 0;

	if (drawingLink && ctrlKey)
	{
		diagram.OverrideCursor = Cursors.Cross;
	}
	else if (diagram.OverrideCursor != null)
	{
		diagram.OverrideCursor = null;
		diagram.Cursor = baseCursor;
	}
} 

  
Back to top
 
IP Logged
 
Joel D.
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 27
Location: Seattle
Joined: Feb 6th, 2017
Re: Mouse cursor plus sign overlay
Reply #4 - Mar 5th, 2020 at 12:10am
Print Post  
Smiley
Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint