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, I am wondering is it possible to intercept the "Selected" behaviour for the nodes on the diagram surface. Right now, seems like User can click anywhere (empty space) on the diagram surface to "Deselect" an item. And, this is the only behaviour that I want to get rid of. Is it possible to NOT Deselect an item whenever user click on empty space? The only way to deselect the item is to select another item. So, meaning ONCE an item being selected, it will always be at least one item stays selected on the diagram. I appreciate if you can point me to the right direction how to intercept this behaviour. Thanks. |
|
|
Hello For this change in selection behaviour, I will need to add an option such as a boolean property to enable it. One thing to consider is what will the behaviour of the marquee selection dragging be now? At the moment, as you drag the mouse on the diagram surface, only nodes within the marquee border will be selected. All other nodes will be deselected. What would you expect the behaviour of this to be now? Either the currently selected nodes could remain selected during the drag operation, and then become deselected if necessary at the end of the operation. Or the currently selected nodes could be deseleted at the start of the drag operation, but then become selected again if the marquee drag operation resulted in no nodes being selected. Both of these feel un-natural. Do you have any other ideas on how the marquee selection should behave with this option? Cheers |
|
|
Well, regarding the marquee selection, the behaviour should be depending on whether the selection is "success" or not. so, you're right, using the first case would be more preferable: Either the currently selected nodes could remain selected during the drag operation, and then become deselected if necessary at the end of the operation. However, I am not sure whether is it possible to make it 'selected' or 'deselected' immediately during the operation, for eg: If the marquee 'touch' / 'include' nodes that are not previously selected, the selected items should reflect immediately and get deselected instead of 'deselected' only after the operation. |
|
|
Hello I have modified the DiagramSurface to help customize the selection behaviour. The DiagramSurface already had events for MarqueeDragStarted and MarqueeDragCompleted. I have now added a MarqueeDragDelta event. When you attach event handlers to these events, you can provide your own selection logic and then set the event arguments Handled property to be true. This will prevent the default logic from taking place. Here is some example code using these events that I believe produces the behaviour you want:
private IList<DiagramElement> _selectedElements; private void ds_MarqueeDragDelta(object sender, MarqueeDragDeltaEventArgs e) } private void ds_MarqueeDragStarted(object sender, MarqueeDragStartedEventArgs e) The drag started handler mostly just need to set Handled to be true. The means that clicking the mouse on the surface doesn't deselect the currently selected nodes. This event handler also stores all the currently selected elements in a collection to be used by the delta handler. The MarqueeDragDeltaEventArgs comes with a collection of all the nodes contained in the marquee rectangle. (This list is affected by the MarqueeSelectBehaviour property which specifies if nodes need to intersect or be fully contained in the rectangle.) In the delta event handler, the stored selection state is maintained/restored if there are no nodes contained within the marquee rectangle. Otherwise, the nodes in the marquee rectangle will be selected. This update will be available through the nightly builds from tomorrow the 6th of October. Let us know how it goes |
|