[Closed] Storing and setting UI defults in/on the UI element?
I have a need to be able to reset a big bunch of UI elements back to their defaults. Obviously spinners have their default value stored in their range property. But for dropdownlists and checkboxes, there is no default that is accessible once the value has changed that I can see. I don’t want to get into storing defaults in external files in this instance. I’m already saving presets (not defaults) in this fashion and while it works fine for what I’m using it for, I don’t want to store defaults externally (or even separately in the same script) cause this tool is constantly being updated and I don’t want to be chasing names and values through thousands of lines of code.
Ideally, I’d like to be able to set something like a user defined property on each UI element that I can call and set back on the element. I’ve even considered using the tooltip to store the default. But I’m already using tooltips on some things for actual tooltips.
The way I’ve come up with will work, but I was wondering if anyone had any other ideas. My idea is as follows:
UI elements are named in this fashion:
chk_preset_on_framerate
So I can run a function on the “controls” of the rollout and matchpattern on filterstring of the name for the word preset and then take the next element and set that as the preset. Obviously filtering for type of UI element and converting the value accordingly.
Cheers,
Cg.
that’s what the structure was implemented for.
struct theDefUI (uiname, defvalue, [type], [range], [scale])
Hey Denis. Thanks for the tip. I know a little about class inheritance from the bit of python that I know, but can max do that properly? I know how to define a struct, but can I make it a new (sub)class of a ui element and inherit all the aspects of the base one but adding a default setting? I’ve been reading the maxscript help and can’t seem to see how it might be possible. Or did I not understand your answer?
Since first posting, I’ve also had someone suggest that maybe dotNet UI elements would be better for me since they already have accessible default values.
Possibly tidier than using structs?
Cheers,
Cg.
i didn’t understand your question. there is no way using the mxs to inherit a max UI control. the using of .NET controls might be a solution.
I think you got the idea of what I was saying cause your answer makes sense to my class inheritance question.
I’m interested in the dotNet stuff and I’m going to look into it.
But I’m also still very keen to understand what you were first suggesting with struct. Could you elaborate a bit more please?
Cheers,
Cg.