[Closed] Reset pickbutton?
Hello, thanks for looking in. I’m in the process of learning more about maxscript, and so far things are going pretty well. However I’m having trouble figuring out how to reset to the initial state of a pickbutton.
Is there a trick to this? I have indeed read the help but it doesn’t seem to have a reset function for a pickbutton. Am I off there?
Thanks so much for any help,
AJ
I do not know of a way to call back to the original UI defaults… I reset it by assigning it back its defaults with a copy of the original string. Does not look like you can create a global value, as the UI expects a string.
try(destroydialog PickTest)catch()
rollout PickTest "UndoTest" width:150 height:60
(
fn Geo_filt obj = superclassof obj ==GeometryClass
button btnReset "Reset "
pickbutton PickBtnA "SelectSomething" width:90 filter:Geo_filt
on PickBtnA picked obj do
(
if obj != undefined do
(
obj.wirecolor = orange
PickBtnA.text = obj.name
)
)
On btnReset pressed do
(
print "reset test"
PickBtnA.text = "SelectSomething"
)
)
createdialog PickTest
Neat. Interesting way to tackle it. I’m new to programming for the most part so I wouldn’t have thought of that. Thanks for the help!
AJ
Edit: This works out perfectly for me. I was able to clear out a variable in the same function so that it really was ‘resetting’ based on this headstart you gave me. Thanks one last time.
to set the button to it’s initial state you should also add the following
PickBtnA.object = undefined
Thank you, that’s a good idea as well. Using both together seems to do everything I was hoping for. Thank you both.
Use what Klunk said and always look in the the help – there’s autoDisplay property for pickButton, no need to set its text when you pick a node and reset it later.
I looked in the help, if I didn’t understand it that’s another story and 100% on me. The help doesn’t mention that autoDisplay = reset if that’s any consolation. I did play with it and all it seemed to do was prevent the text from changing on target, but setting it to false after did not change it back, just disabled the function. Maybe I did it wrong. (total novice to max script, have some experience with .mel though…)
Simply running the “= undefined” command does not actually clear out the button text however, so in my opinion it is necessary as the user will be fooled into thinking that the box still has a target as the name doesn’t change on the button. So… you’re both right really. I ended up using both and it seems to be a total reset with 1 extra line of code that clears out my global variables used for the pickbutton.
Or am I confused?
I ended up with this:
on ResetClothingSize pressed do
(
PickClothingLarge.text = "Pick Large Clothing"
PickClothingLarge.object = undefined
PickClothingMedium.text = "Pick Medium Clothing"
PickClothingMedium.object = undefined
PickClothingSmall.text = "Pick Small Clothing"
PickClothingSmall.object = undefined
PickClothingLargeVar = undefined
PickClothingMediumVar = undefined
PickClothingSmallVar = undefined
)
Maybe not elegant or anything but totally does the trick.
try destroyDialog example catch()
rollout example "Example"
(
pickButton pbSample "Pick Something" autoDisplay:true
button btnReset "Reset"
on btnReset pressed do pbSample.object = undefined
)
createDialog example