I'm having a terrible time trying to get my UI dialog to properly show text fields as they are dynamically added to a group.
There's no issue on Mac, but on Windows the fields will not show what is being typed into them.
I've tried various refresh/redraw methods, but nothing seems to work...
Any help would be greatly appreciated!
Mac: Windows:
Here is the simplified version of my script:
Code: Select all
#target photoshop
var dlg = new Window('dialog', 'Dynamic Fields Test');
dlg.populateBtn = dlg.add('button', undefined, 'Add fields', {name:'ok'});
dlg.closeBtn = dlg.add('button', undefined, 'Close', {name:'cancel'});
// Create a panel to hold fields group
dlg.dynamicPanel = dlg.add('panel', undefined, "Dynamic Fields:");
dlg.dynamicPanel.orientation = 'column';
dlg.dynamicPanel.alignChildren = 'left';
// Create group to add fields to
dlg.dynamicPanel.fields = dlg.dynamicPanel.add('group', undefined, undefined);
dlg.dynamicPanel.fields.orientation = 'column';
dlg.populateBtn.onClick = function() { dlg.close(); }
dlg.populateBtn.onClick = function()
{
try
{
// Create 10 dynamic edit text fields
for(var i = 0; i < 10; i++)
{
dlg.dynamicPanel.fields[i] = dlg.dynamicPanel.fields.add('group', undefined, undefined);
dlg.dynamicPanel.fields[i].orientation = 'row';
dlg.dynamicPanel.fields[i].title = dlg.dynamicPanel.fields[i].add('statictext', undefined, 'Dynamic field' + i);
dlg.dynamicPanel.fields[i].textField = dlg.dynamicPanel.fields[i].add('edittext {text:"", characters:10, justify:"left"}');
}
// Try our best to refresh the window
dlg.layout.layout(true);
} catch(e) {
$.writeln(e + " - line: " + e.line);
}
}
dlg.center();
dlg.show();