Hi all,
2. Sometimes for vertical line also it does not recognize mouse move and does not raise ObjectEnterLeave event. I can provide sample code if required.
Hi all,
Yes, if you could send a small sample that duplicates the problem, that’s always a huge help.
Hi Jake,
goView1.Document.Add(pGDDrw);
goView1.Document.Add(pGDDrw1);
goView1.DocScale = .6f;
}
OK. You are creating an object that is smaller than the resolution of the mouse.
Mouse X 262 maps to doc X of 433.3333
Mouse X 263 maps to doc X of 434.9999
Your object (a very thin vertical line) has a Left X of 434.086 and a Right X of 434.336.
So, your object lives in the space between the 2 points reported by the mouse movement.
So, technically, Go is doing the right thing here, although not being able to do a hit test on an object you can see is a bit non-intuitive.
If you really want a PenWidth of .25, you’ll have to derive from GoDrawing and override ContainsPoint and add some code for “very very close”.
Hi Jake,
GoDrawing pGDDrw3 = new GoDrawing();
pGDDrw3.StartAt(new PointF((float)358.7006, (float)-477.6309));
pGDDrw3.LineTo(new PointF((float)434.211456, (float)-477.6309));
pGDDrw3.PenWidth = 0.25f;
GoDrawing pGDDrw4 = new GoDrawing();
pGDDrw4.StartAt(new PointF((float)358.709381, (float)-232.21843));
pGDDrw4.LineTo(new PointF((float)434.2202, (float)-232.21843));
pGDDrw4.PenWidth = 0.25f;
GoDrawing pGDDrw5 = new GoDrawing();
pGDDrw5.StartAt(new PointF((float)200, (float)-232.21843));
pGDDrw5.LineTo(new PointF((float)250, (float)-232.21843));
pGDDrw5.LineTo(new PointF((float)250, (float)-282.21843));
pGDDrw5.PenWidth = 0.25f;
GoDrawing pGDDrw6 = new GoDrawing();
pGDDrw6.StartAt(new PointF((float)358.709381, (float)-232.2184));
pGDDrw6.CurveTo(new PointF((float)386.192535, (float)-198.155746), new PointF((float)418.047455, (float)-204.472412), new PointF((float)434.229, (float)-232.5601));
pGDDrw6.PenWidth = 0.25f;
goView1.Document.Add(pGDDrw1);
goView1.Document.Add(pGDDrw2);
goView1.Document.Add(pGDDrw3);
goView1.Document.Add(pGDDrw4);
goView1.Document.Add(pGDDrw5);
goView1.Document.Add(pGDDrw6);
goView1.DocScale = 1f;
Imagine a sheet of grid paper with a 1/4" (quarter inch) grid. Now take a felt tip pen, shut your eyes, and make 6 random dots on the page.
The intersecting points on the grid paper are the coordinates returned by mouse move. The grid lines the locations where a “hit” would be detected.
If the dots you make on the paper intersect the lines, a “hit” would be detected by GoDiagram. If the dot doesn’t hit a line, it wouldn’t. That’s why you are seeing the behavior you are.
On further thought, it may be better to compute the bounding box of the line to be larger than it is than to change the hit test code.
I can have something for you later today.
Also consider that if there are several such figures very close to each other, only one of them will be pickable with the mouse. They are effectively on top of each other.
OK. First the code, then the caveat.
[Serializable]
public class GoDrawingThin : GoDrawing {
protected override RectangleF ComputeBounds() {
RectangleF r = base.ComputeBounds();
if (r.Width == 0.0) {
float w = 1.7f;
r.X -= w/2;
r.Width = w;
}
return r;
}
}
The “distance” between pixels when you are at DocScale = .6 is 1.666. So, potentially, any object with less width than that can sit in the area between the pickable locations.
So, the value 1.7 in the code is actually bigger than it needs to be, since the .25 width of the Pen is added in when doing the hit test.
This also only handles vertical lines, I don’t handle Height == 0.
Now, the caveat: This value changes at different DocScales. At DocScale = .24, the distance is 4.1666.
This all makes sense… if you zoom out, things get smaller and smaller, the distance between objects on the screen gets smaller. It has to be harder to point at them individually. (this echos Walter’s comment above)
Notice our GoStroke class has a PickMargin property, which adds some width to lines over and above the PenWidth. This defaults to 3.
If you can switch to GoStoke from GoDrawing, you wouldn’t see this problem at DocScale .6.
But… I don’t understand your app, why you are using PenWidth of .25, why you are using GoDrawing for a line, or how much “zoom” would be expected. So these are the trade-offs you’ll have to make. I’m just here to explain how it works.
Hi Jake,
Excellent reasons then, I see why you’ve made those tradeoffs. Hopefully my code above gets you past this issue.