PDA

View Full Version : Changing UI defaults automatically/ refreshing the user dialog w/changing values



jeric_synergy
09-30-2012, 12:04 AM
I have a item name prefix string that I would like to change depending on what TYPE of light a user decides to create.

That is, if the user choses "POINT LIGHT", the default prefix changes to "Point-".

In this code snippet, the string requester is preloaded with var2, ="Light-". Depending on which light type is selected, I'd like the dialog to change this preloaded text to something appropriate. Right now of course it is static. How do I get LScript to redraw/refresh the dialog to reflect changing light type?


var1 = "Light-"; //'default' prefix to light name
c1 = ctlstring("Light Name",var1);

Thanks.

xchrisx
09-30-2012, 09:23 PM
I believe what you want to do is one of those situations where you would have to parse the scene file unfortunately. So what you would have to do is run your script which would parse the current scene file looking for the selected light's ID then read the light type. Once it finds the light type it would be stored in a variable, and finally when creating the requester it would have to look at that variable to set the text string.

jeric_synergy
09-30-2012, 11:12 PM
Nahh, you misunderstand me: the light type is fully contingent on the script itself, it doesn't reference anything in the existing scene.

When this script creates a light, it prefaces the name with the light type. Of course, as the user chooses the various types available, I want the preloaded value (string) in the text dialog to change with the type.

In the dox I've seen some verbiage in Extreme Programmerese that suggests to me that there're methods of forcing the UI to update after its initial drawing, so if the user changes something the UI can change accordingly, but it's convoluted enough I thought I'd throw out a request here first for clarification.

The 'light types' UI is radio buttons, so if the UI updated everytime a radio button changed state, that would do it.

(I could explain in the script to the user with explanatory static text, but that's no fun.) :ohmy:

xchrisx
09-30-2012, 11:34 PM
There are no radio buttons in lscript interfaces, however I believe this is roughly what you are describing (although I am using a popup list).


@warnings
@version 2.2
@script generic


lightlist = @"Point","Distant","Spotlight"@;
lightprefixlist = @"Point-","Distant-","Spotlight-"@;
c2;

generic
{
var1 = 1;
var2 = "string";

reqbegin("My Requester");
reqsize(276,142);

c1 = ctlpopup("Popup",var1,lightlist);
c2 = ctlstring("Text Edit",var2);
ctlrefresh(c1,"refresh");

return if !reqpost();

var1 = getvalue(c1);
var2 = getvalue(c2);

reqend();
}


refresh: value
{
setvalue(c2,lightprefixlist[value]);
}

jeric_synergy
10-01-2012, 06:27 AM
There are no radio buttons in lscript interfaces,
I refer to all "only one out of multiple choices" UI functionality as radio buttons, since that's the derivation.

I cut&pasted your code and got an error, "Line 20, callback function refresh() does not exist". I'll look into that when I'm awake.

Thanks for the example.

Transcribing the above error made me wish that ALL such text was selectable-- making a screen grab is such a PITA, and so is re-typing something already on the screen.
+++
EDIT: Yes, that works perfectly (lesson 4 me: don't try to examine code while asleep.) Cool, thanks, it's gonna be a neat little script.

xchrisx
10-01-2012, 10:36 AM
There is actually more text in there if you scroll down. It just happened to be cut off by the height of the code box. You need the refresh() udf at the bottom.

jeric_synergy
10-01-2012, 12:05 PM
There is actually more text in there if you scroll down. It just happened to be cut off by the height of the code box. You need the refresh() udf at the bottom.
Bingo. Exactly what happened. :thumbsup: