Skip to main content
Participant
January 13, 2015
Question

StaticText Character Limitation

  • January 13, 2015
  • 2 replies
  • 572 views

Hey guys,

I'm experiencing a weird issue with StaticText, specifically it being limited in characters once I set an initial text value. Basically I'm building a progress bar window: I have a function that builds the UI with all the elements/text, and another function that updates the UI.

When I build the UI and set the initial text value to "XXX", then attempt to change it via my updateProgressBar function, the new text value is limited to 3 characters ("XXX"). Likewise, if I change the initial text value to nothing "", when I update the text, it displays nothing. Basically, whatever I set as the initial text in the UI, that's the max # of characters I can have, even when trying to update the text to something else via my updateProgressBar function. The weird thing is, everything is 100% functional and the progress bar/text DOES update, it's just the StaticText is limited in # of characters.

Anyone experience this issue? I'm thinking it has something to do with the way I'm building the UI/functions. Any help would greatly be appreciated.

Thanks!

// Build progress bar

var progressBarWindow = buildProgressBar();

var totalLayers = myPalette.grp.mainGroup.extrusionGroup.extrusionCopies.text * numSelectedLayers;

var progressCounter = 0;

// Update progress bar

progressCounter = progressCounter + 1;

updateProgressBar(progressBarWindow, 0, totalLayers, progressCounter);

// Function that updates progress bar

function updateProgressBar(progressWindow, min, max, curValue){

       

        progressWindow.grp.mainPanel.progressBarUI.minvalue = min;

        progressWindow.grp.mainPanel.progressBarUI.maxvalue = max;

        progressWindow.grp.mainPanel.progressBarUI.value = curValue;

       

        progressWindow.grp.mainPanel.progressTxt.text = "Processing: " + curValue + "/" + max + " layers";

}

// Builds window for progress bar

function buildProgressBar() {

   

    var myWin = new Window("palette", "Extruding...", undefined, {resizeable:false});

    if (myWin != null) {

       

                var res = "group {orientation:'column', alignment:['fill','fill'],\

                                    mainPanel: Group {text:'Add/Edit List Item', orientation:'column', alignment:['fill', 'fill'], minimumSize:['250','50'], spacing:5 ,\

                                        progressBarUI: Progressbar {alignment:['fill','top']} ,\

                                        progressTxt: StaticText {text:'XXXXXXXXXXXXXXXXXXXXXX', alignment:['left','top']},\

                                    },\

                                }";

                               

                myWin.grp = myWin.add(res);

               

               

                myWin.layout.layout(true);

                myWin.layout.resize();              

                myWin.onResizing = myWin.onResize = function(){this.layout.resize()};

                myWin.show();

                return myWin;

    }

   

}

This topic has been closed for replies.

2 replies

Participant
January 14, 2015

Thanks Arie and Xavier, fixed the problem with your suggested alignment/preferredSize!

Legend
January 13, 2015

StaticText can be tricky, so you may want to double check that the width of the StaticText object is wider than the initial three characters that you are using.  For the StaticText object, you might try making the alignment ['fill', 'top'] instead of ['left', 'top'].  Also, you should add a preferredSize property where the width is -1, something like preferredSize: [-1, 25].  That would mean that the ScriptUI engine determines the size for the width, and the height would be 25.  Not sure if that will solve the issue you are seeing, but that might be a good place to start troubleshooting...


Hope it helps!


-Arie

UQg
Legend
January 13, 2015

You can also specify a number of characters:

progressTxt: StaticText {text:'', characters: 40, justify: 'left', alignment:['center','top']},\ 

That's about the same thing as setting the width.


Xavier.