Selection not based on bounds


#1

What must be done to include in the selection objects that are just
partially in the selection ‘rubber band’ (when dragging to make a
selection)?

Or for example in the case of a node with text (iconic node) to include
the node in the selection when the icon (not necessary the text) is in
the selection rectangle.

Thanks for any help.


#2

It is the case that GoView.SelectInRectangle just considers each object’s SelectionObject, so that the user doesn’t have to surround the whole object, but just the part of the object that is the GoObject.SelectionObject. In the case of GoIconicNodes, users only need to surround the Icon in order to select the node–they don’t need to include the Label.
If you want to change the behavior, you can certainly override GoObject.SelectionObject and/or GoView.SelectInRectangle to do whatever you want. If you override the latter, remember to consider several things: whether the object is visible (GoObject.CanView()) and selectable (GoObject.CanSelect()) and whether to recurse into GoGroups (which it does).


#3

Unfortnuately because of this:

http://www.nwoods.com/forum/forum_posts.asp?TID=500&PN =2
The selection object is the whole object.

What is realy needed is to select objects even if they are partialy in
the selection rectangle so it seems that the solution is to override
SelectInRectangle.

Thanks you for your help.


#4

If for some reason you are reluctant to subclass GoView, you can just override GoToolRubberBanding.DoRubberBand to call your own method for selecting objects given a rectangle. Here’s the definition:
public virtual void DoRubberBand(Rectangle box) { // BOX is in view coordinates!
Size dragSize = System.Windows.Forms.SystemInformation.DragSize;
if (box.Width <= dragSize.Width/2 && box.Height <= dragSize.Height/2) {
DoSelect(this.LastInput);
// whether or not we found and/or selected anything, call DoClick
DoClick(this.LastInput);
} else {
RectangleF docRect = this.View.ConvertViewToDoc(box);
this.View.SelectInRectangle(docRect);
}
}


#5

I did override SelectInRectangle and it works perfectly (until now )