locked
Allow lineshape to pass mouseup and mousedown events to pass to the underlying panel

    Question

  • I have three line shape control that I have added to a shape container which is on a custom panel.  I need the custom panel to paint some specific graphics that calculates a scientific formula.

    I am using the lineshape control to set a line against the plotted data.  I found that the lineshape control is intercepting the mousedown, mouseup events.  I cannot get the mouseup event to get called by the lineshape control if the lineshape is moved.  I can use the underlying mousemove event when the line is moving 

    I would like to allow the lineshape control to allow the panel below the shape container and line shapes to consume the event.  Can I do that?  If not why is the lineshape control not calling the mouseup if the lineshape control is moved?  How can I get the lineshape to consume the mouseup event?

    Best regards

    Monday, August 17, 2009 3:33 AM

Answers

  • Hi Mark,

    The Shape control is managed by a container control called ShapeContainer:  http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.shapecontainer.aspx

    When the mouse is down on a shape, then all the events are actually managed by the ShapeContainer.
    So for this case:

    You mouse down on a shape,
    Hold it down and move the mouse out to the shape area.  
    Then mouse up.
    There is no event.

    You can hook up a MouseUp event through the ShapeContainer, I've tested it.
    Hope this can work for your app.

    Thanks!

    John
    John Chen -- See my team blog: http://blogs.msdn.com/vsdata. All my posts are provided "AS IS" with no warranties, and confer no rights.
    Monday, August 17, 2009 10:52 PM
    Moderator

All replies

  • Hello Mark,

    Can I confirm your question?
    "I cannot get the mouseup event to get called by the lineshape control if the lineshape is moved. "

    What do you mean the  lineshape is moved?

    I can repro this behavior,
    You mouse down on a shape,
    Hold it down and move the mouse out to the shape area.  
    Then mouse up.
    There is no event.

    Are you talking about this?

    Thanks!
    John Chen -- See my team blog: http://blogs.msdn.com/vsdata. All my posts are provided "AS IS" with no warranties, and confer no rights.
    Monday, August 17, 2009 6:51 AM
    Moderator
  • Thank you for the help.

    I have mousedown, mousemove and mouseup events on the panel that is the base of the control.  I add a shapecontainer and three lineshapes to the shapecontainer.  The mousedown, mousemove and mouseup events work fine when the user is grabbing and moving the lineshape but if the user does a mousemove directly ontop of the lineshape the lineshape control captures the event; ideally I could have the lineshape ignore the event and let the panel below the lineshape consume the event.  Then I would be done.  But maybe that is not possible? 

    I added two event handler: mousedown and mouseup to the lineshape and now when the user does a mousedown directly on the lineshape I have some custom logic to see if the user selected the left or the right end of the line and set a variable that allows the lineshape to be moved.  I continue to use the MouseMove event that is in the underlying panel (it seems to work but the lineshape is not updating the location during the mousemove like it does when the user selects outside of the lineshape...) then I wait for a MouseUp but the MouseUp is never called.  Then the user thinks the line is no longer movable by the control the mouseup event from the panel "frees" the line and no longer is the line moved.

    So why is the mouseup not called?  Again if I could allow the mousedown, mousemove and mouseup events to pass through to the underlying panel then everything would be working great.  It is only when the user selects directly on the lineshape that I have a problem.

    Best regards,

    Mark Kilroy   

     
    Monday, August 17, 2009 3:47 PM
  • Hi Mark,

    The Shape control is managed by a container control called ShapeContainer:  http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.powerpacks.shapecontainer.aspx

    When the mouse is down on a shape, then all the events are actually managed by the ShapeContainer.
    So for this case:

    You mouse down on a shape,
    Hold it down and move the mouse out to the shape area.  
    Then mouse up.
    There is no event.

    You can hook up a MouseUp event through the ShapeContainer, I've tested it.
    Hope this can work for your app.

    Thanks!

    John
    John Chen -- See my team blog: http://blogs.msdn.com/vsdata. All my posts are provided "AS IS" with no warranties, and confer no rights.
    Monday, August 17, 2009 10:52 PM
    Moderator
  • Hi John , 


    Thanks for providing this one . Its working , but how the movement of line is slipping from the mousepointer .


    The mouse pointer not holding the position of the Ctrl e.X and e.Y . What to do about that one ?

    How the mouse pointer can be attached to the Line control while moving so tat linecontrol can move freely ?

    Regards

    VS
    Friday, February 19, 2010 10:18 AM