Need help with a script handler for interactiveViewChange('zoomarea')

Next
 From:  ed (EDDYF)
10403.1 
Hi Michael -

I need help using interactiveViewChange('zoomarea') within a script.

I have tried various event handlers inside my ZmArea() function to proceed after interactiveViewChange('zoomarea') is finished.

The only way I have found that allows interactiveViewChange('zoomarea') to finish is to add a "Continue" button that allows the script to progress when clicked.

I'd like to not use a Continue button and have the script to proceed automatically when the user releases the mouse after drawing the zoom rectangle. Is that possible?

Ed Ferguson

code:
<html xmlns:moi>
	<head>
		<link rel="stylesheet" href="moi://ui/moi.css" type="text/css">
		
<script>
  // _TestZoomArea.htm
			
  moi.ui.mainWindow.viewpanel.mode = '3D';
	
	
function Main()
{
moi.ui.alert( 'Do main stuff here - then Zoom Area' ) ;
// do main stuff
//
// Zoom Area
ZmArea();
//
//
moi.ui.alert( 'Finish doing more main stuff here' ) ;
// more main stuff	
}
	
			
function ZmArea()
{
	moi.ui.mainWindow.viewpanel.getViewport('3D').interactiveViewChange('zoomarea');
					
	    while (1)
	    {	
			moi.ui.commandDialog.waitForEvent();
					  
			if ( moi.ui.commandDialog.event === 'continue' ) {
               return;
            }
		
	     }
}

</script>
	
</head>
	
	<body class="commandbody">
		<div style="text-align:center; font-weight:bold;">
			Test Zoom Area
		</div>
		<div class="commandoptions">
			<table style="width:100%" cellspacing="0" cellpadding="0">
				<tr>
					<td><moi:PushButton class="SlimBtn" id="startbutton" onbuttonclick="Main();">Start Test</moi:PushButton></td>
					<td><moi:PushButton class="SlimBtn" id="continue" >Continue</moi:PushButton></td>
				</tr>
			</table>
		</div>
	</body>
</html>



code:
// _TestZoomArea.js
function DoZoomArea()

{
    var dlg = moi.ui.commandDialog;
	
	while ( 1 )
	{
		// Wait for user input
		
		if ( !dlg.waitForEvent() ) // if waitForEvent returns false the command is being canceled.
			return false;
			
		if ( dlg.event == 'quit' ) // User Quit
			break;
	}

	if ( moi.ui.commandDialog.event == 'cancel' ) {  // User Canceled
            moi.ui.commandUI.cancel(); 
            return;
        }
 }

DoZoomArea();
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10403.2 In reply to 10403.1 
Hi Ed, unfortunately I don't think it is possible currently for a script to use interactiveViewChange() in this way.

The way view.interactiveViewChange() works currently is that it posts a message and then lets the current call stack unwind and doesn't start the view change loop until when the message is processed.

I will add in an optional 2nd parameter to interactiveViewChange() to make it go into its modal loop immediately rather than posting a message, so in v5 you will be able to do it like this without setting up your own event loop:

moi.ui.mainWindow.viewpanel.getViewport('3D').interactiveViewChange('zoomarea', true);

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  ed (EDDYF)
10403.3 In reply to 10403.2 
Thanks Michael - I'll use the Continue button for now.

Looking forward to Ver 5.

Ed Ferguson
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10403.4 In reply to 10403.3 
Hi Ed,

Checking moi.majorVersionNumber might be helpful?

code:
    if ( moi.majorVersionNumber < 5) {
        moi.ui.mainWindow.viewpanel.getViewport('3D').interactiveViewChange('zoomarea');
	
	while (1)
	{	
	    moi.ui.commandDialog.waitForEvent();
	    
	    if ( moi.ui.commandDialog.event === 'continue' ) {
                return;
            }
	    
	}
    } else
        moi.ui.mainWindow.viewpanel.getViewport('3D').interactiveViewChange('zoomarea', true);


--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  ed (EDDYF)
10403.5 In reply to 10403.4 
Good idea Larry - We'll do.

Ed Ferguson
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All