This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi Jason, We are trying to implement a smart selection mechanism. The details are not too interesting but anyway, this is what we are trying to achieve: - SHIFT + Marquee-Select adds nodes to the current selection in real-time. - CTRL + Marquee-Select select subtracts node to the current selection in real time. - SHIFT + Click always adds a single node to the current selection. - CTRL + Click toggles the selection of a single node to the current selection. We are struggling with this. In fact, it feels we are kind of fighting with Mindscape, trying to undo what is being done automatically. We need to be able to disable the auto-deselection of node when clicking on an empty surface when the user holds either the shift key or the ctrl key. What would be the best way to do it? Cause what we are doing now is registering to the selection changed event and if the SelectedItem is set to null (we saw in your code that this is what you guys are doing) - we revert the selection. But reverting the selection causes us other problems. Can you pls advise? Thanx, Gili |
|
|
Hi Gili, You may be able to disable the deselect-on-click behaviour by attaching event handlers to the DiagramSurface.MarqueeDragStarted and DiagramSurface.MarqueeDragDelta events. In the Started event handler, check to see if Shift or Ctrl is being held, and if so, set e.Handled = true. This will disable the deselection on click. In the Delta event handler, you can write your own logic to perform the node selection. The default logic is to force only elements within the marquee rectangle to be selected - which will produce the same issue as when you simply click an empty space. So your logic would be to select the element that are within the rectangle, but don't update the state of any other elements - so selected nodes stay selected. Here's an example:
You may want to expand on this logic to check if Ctrl is being held, and if so, set the selected states to false, instead of true. This is not an MVVM solution, so you could wrap this all up in an attached property if you wish. Let me know if you have further questions about any of this. -Jason Fauchelle |
|
|
Great Jason, I'll give it a try. |
|
|
Thank you! It worked perfectly. |
|