Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Using OverrideCursor (Read 1988 times)
Amosius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 75
Joined: Sep 2nd, 2010
Using OverrideCursor
Feb 22nd, 2011 at 5:01pm
Print Post  
Hi,

i want to change the cursor during a drag/drop action. I have a scrollviewer (svDiagram) with the diagram inside (dgDiagram). I use the following code:

[code]
private void List_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
var source = (FrameworkElement)e.OriginalSource;
DragDrop.DoDragDrop(listMarkups, source, DragDropEffects.Copy);
}

private void DragEnterNode(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Image)))
{
dgDiagram.OverrideCursor = Cursors.Hand; //does not work

e.Effects = DragDropEffects.Copy;
}
else
{
e.Effects = DragDropEffects.None;
}
}

protected override void OnGiveFeedback(GiveFeedbackEventArgs e)
{
e.UseDefaultCursors = false;
}

private void DropNode(object sender, DragEventArgs e)
{
...
}

[/code]

Drag / Drop action works fine. But i can't change the cursor.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Using OverrideCursor
Reply #1 - Feb 22nd, 2011 at 6:53pm
Print Post  
Hi,

During drag-and-drop the cursor icon is controlled by the source control. You can change it by handling the GiveFeedback event:

Code
Select All
listMarkups.GiveFeedback += OnGiveFeedback;
DragDrop.DoDragDrop(listMarkups, "test", DragDropEffects.Copy);
listMarkups.GiveFeedback -= OnGiveFeedback;

void OnGiveFeedback(object sender, GiveFeedbackEventArgs e)
{
	Mouse.SetCursor(Cursors.Hand);
	e.UseDefaultCursors = false;
	e.Handled = true;
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Amosius
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 75
Joined: Sep 2nd, 2010
Re: Using OverrideCursor
Reply #2 - Feb 23rd, 2011 at 11:04am
Print Post  
Worked. Thank you very much.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint