Hi Tudor,
I wish it was that simple!
I removed my try/catch wrappers from the calls to pointpicker.waitForEvent() and added code to check for pointpicker.event == 'cancel'. This does not work any better. Pressing Esc in the inner function (commandLeader()) results in the CPlane being reset upon exit, but pressing Esc in the outer function (doCoordinates()) causes an exit without resetting the CPlane. Next I removed the try/catch around the call to doCoordinates() shown above and this results in an Esc pressed for either function not resetting the CPlane.
Here's a simplification of the code to illustrate the structure:
code:
function coordinateLeader( pointpicker, leaders) {
[...]
while ( true) {
if ( !pointpicker.waitForEvent() ) { << Esc here results in an exit without the CPlane being reset
return false;
}
if ( pointpicker.event == 'finished' ) {
[...]
}
if ( pointpicker.event == 'done' ) {
[...]
break;
}
if ( pointpicker.event == 'cancel' )
return false;
if ( pointpicker.event == 'undo' ) {
[...]
return false;
}
}
[...]
return true;
}
function doCoordinates() {
if ( !WaitForDialogDone() )
return;
if ( moi.ui.commandUI.AdjustOrigin.value)
moi.view.setCPlaneInteractive();
[...]
var pointpicker = moi.ui.createPointPicker();
pointpicker.allowNestedCancel();
while ( true) {
[...]
if ( !pointpicker.waitForEvent() ) { << Esc here results in an exit without the CPlane being reset
return false;
}
if ( pointpicker.event == 'done' )
return true;
if ( pointpicker.event == 'cancel' )
return false;
if ( pointpicker.event == 'undo' && leaders.length > 0 ) {
[...]
continue;
}
coordinateLeader( pointpicker, leaders);
pointpicker.reset();
pointpicker.allowNestedCancel();
}
}
var savedcf = moi.view.getCPlane();
doCoordinates();
moi.view.setCPlane( savedcf);
--Larry
|