Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've written a function to create a polygon based on geometry collected from the IRubberBand interface as follows:

ITrackCancel esc = new CancelTrackerClass();
esc.CancelOnKeyPress = true;
esc.Reset();
ArcMap.Document.ActiveView.ScreenDisplay.CancelTracker = esc;
//MessageBox.Show("This will allow a key press to cancel the tracking if uncommented");
IRubberBand rubberBand = new RubberPolygonClass();
IScreenDisplay screenDisplay = ArcMap.Document.ActiveView.ScreenDisplay;
IGeometry geometry = rubberBand.TrackNew(screenDisplay, null);

I am attempting to cancel the tracking of the polygon (i.e. cancel the drawing operation) on key press. The above code will not cancel the tracking unless I insert a MessageBox display somewhere before the tracking begins. My guess is that this problem is somehow related to this issue: How to use ITrackCancel to escape IRubberBand track? . I'm also a bit skeptical of how I've hooked into the active view. If anyone could provide some insight on how to best cancel this operation without an awkward messagebox being involved I would certainly appreciate it.

share|improve this question
    
I wonder if this might be a threading issue. Try executing your function on the main UI thread; see this answer for an example: ArcGIS 10 add-in: ComboBox add-in component focus issue –  blah238 Jul 6 '12 at 22:03
    
Thanks, I'll give this a shot and let you know if it fixes the issue. It sounds plausible. –  AHigh Jul 6 '12 at 23:24
    
Calling function within the main method does seem to solve the problem. This is in an ArcGIS AddIn hooked to a Tool class and I would have liked to initiate this in a OnMouseDown event, but alas. –  AHigh Jul 24 '12 at 17:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.