Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Raise MouseLeave events with MouseButton pressed (Read 4191 times)
Amx
YaBB Newbies
*
Offline


digito ergo sum

Posts: 21
Joined: Jan 19th, 2010
Raise MouseLeave events with MouseButton pressed
Mar 5th, 2010 at 11:03am
Print Post  
Hi Stoyan,

I Have two ShapeNodes (refer them as "A" and "B") on diagram. I need to connect them by dragging a link from A to B, with a custom feature:
- When Mouse Leave "A" during link drag operation, a temporary ShapeNode must be drawn. (depending a keypressed, node must follow mouse pointer or will be drawn in a fixed position)
- When Mouse Enter "B" the temporary node must be deleted

I Have
Code
Select All
Diagram.Behavior = Behavior.DrawLinks 



"A" and "B" Shape Nodes attaching event handlers:
Code
Select All
node.Adorner.MouseLeave += new MouseEventHandler(node_MouseLeave);
            node.Adorner.MouseEnter += new MouseEventHandler(node_MouseEnter);
 



MouseLeave event handler:
Code
Select All
protected void node_MouseLeave(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                  // Do something like draw temporary node
             }

        }
 



The problem is that MouseEnter and MouseLeave events will never raised when mouse button is pressed... How can I solve?

Thanks for your help,
Best Regards
Amx
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Raise MouseLeave events with MouseButton press
Reply #1 - Mar 5th, 2010 at 11:44am
Print Post  
Hi,

Try doing that through the LinkCreating event, depending on whether args.Destination is set. Otherwise you might call Diagram.RelaseMouseCapture in response to MouseDown in order to get Enter / Leave events, but that might lead to unexpected results if the mouse pointer leaves the diagram while drawing.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Amx
YaBB Newbies
*
Offline


digito ergo sum

Posts: 21
Joined: Jan 19th, 2010
Re: Raise MouseLeave events with MouseButton press
Reply #2 - Mar 5th, 2010 at 4:45pm
Print Post  
Calling Diagram.RelaseMouseCapture gives me more control but I encounter another problem: MouseLeave events is raised many times, not only when I really leave node but also when I press mouse left button over node.

I tried also with Diagram.Behavior = Behavior.DoNothing, but unsuccessfully (MouseLeave event is raised when I click on node).

There is a mode to avoid this event to be raised when I click on node?

Thanks,
Amx
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Raise MouseLeave events with MouseButton press
Reply #3 - Mar 8th, 2010 at 9:30am
Print Post  
The same seems to happen if you add buttons to a Canvas and call the SetCapture and ReleaseCapture methods in response to mouse events, so I suppose the only way to stop that is to override the Diagram.OnMousedown method so that it does not capture the mouse. The only methods called in MouseDown are CaptureMouse() and Focus(), so you might leave just the latter.

Otherwise you could implement what you need by handling LinkCreating and checking if args.Destination is set, or perhaps by handling MouseMove and calling diagram.GetNodeAt to find out if there's a node under the mouse pointer.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Amx
YaBB Newbies
*
Offline


digito ergo sum

Posts: 21
Joined: Jan 19th, 2010
Re: Raise MouseLeave events with MouseButton press
Reply #4 - Mar 9th, 2010 at 11:49am
Print Post  
Hi, Stoyan

At this moment, I have made this workaround you suggested me, handling LinkCreating event in conjunction with MouseMove and seems to work correctly.

But I need to know if in the future it will be possible to isolate MouseEnter/Leave events in order to give my company a complete picture of product features.

Thanks for your help,
Amx
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Raise MouseLeave events with MouseButton press
Reply #5 - Mar 9th, 2010 at 4:00pm
Print Post  
We can add some property to disable the CaptureMouse call, for the May'2010 release. Enter/Leave should work then also after the mouse button has been pressed.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint