Script Help
All  1-5  6-11

Previous
Next
 From:  Barry-H
7933.6 
Hi Max,
Thanks for your example am I correct this creates a slider input ?
I am a novice to scripting and have tried coping parts of an existing script to allow
a numeric input into Michael's MirrorRotateHistoryArray.js to alter the amount of copies.
The attached photo shows the Htm file is producing the input box.
So a basic input box is what I'm after.
Attached is the Htm file.
Any pointers would be great.
Cheers
Barry

EDITED: 30 Jan 2021 by BARRY-H

Image Attachments:
Size: 141.3 KB, Downloaded: 34 times, Dimensions: 1281x965px
  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
7933.7 In reply to 7933.6 
Hi Barry - so the thing where your new UI is flashing and going away is because the script currently just runs through and exits, and when it exits the command ends, and when the command ends the command UI is torn down and goes away.

So in order to make some UI appear and stay up there to interact with, you would need to modify the .js file as well, to make it go into an event loop instead of just running through and exiting. I'll also make an example for you.

- 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:  Michael Gibson
7933.8 In reply to 7933.6 
And also I see that right now in your .htm file you've put in a <input> element for your type in box. Instead of that you would usually want to use a MoI-speciifc control like a <moi:NumericInput> instead of just a plain <input> . The MoI control will do various things like initialize with the default value and persist the same value between command runs, and emit UI events to an event loop, which won't happen with the totally generic <input> element.

If you look at any of the other .htm files in MoI's commands folder to see other examples you should see that they are all using things like <moi:NumericInput> .

- 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:  Michael Gibson
7933.9 In reply to 7933.6 
Hi Barry, I've attached here an example that uses your UI.

So first I changed the UI file to use a <moi:NumericInput> control like I described above.

Then I added an #include to bring in the library function WaitForDialogDone(), you can look at the code for this in the WaitForDialogDone.js file in the commands folder - it spins an event loop until the user pushes Done or Cancel, so the command will not just run through and exit like it was doing in the previous version.

Then right below the wait line there's the line to retrieve the value of your input field to use for the script.


The other way you could set it up is if you wanted to make it more interactive with things updating every time you changed the input field, you would need to make your own event loop instead of using the prepackaged one in WaitForDialogDone(), and make it pay attention to an event named 'qty' (the id value of your control), and then go through the calculations at that time rather than doing it as a separate stage like it does now. That would involve a bit more changes to the script though.

Basically though in an event loop any controls with id values will trigger a UI event of that same id name so the script can respond to changed values immediately. But it tends to simplify the logic a bit when you gather values in a separate stage like this is doing now.

Hope this helps!

- Michael


EDIT: oops, forgot attachments - added them now.

EDITED: 27 Apr 2016 by MICHAEL GIBSON


  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:  Mik (MIKULAS)
7933.10 In reply to 7933.9 
Very nice script for guilloche generating :-)




Mik

  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:  Barry-H
7933.11 
Hi Michael,
thanks for the help I will have a look and hopefully be able to follow the logic.
Many Thanks.
Barry
  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

 

 
 
Show messages: All  1-5  6-11