Redraw issue when adding text fields to UI window

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Infiniti1Up
Posts: 2
Joined: Fri Jan 06, 2017 2:02 am

Redraw issue when adding text fields to UI window

Post by Infiniti1Up »

Hi!

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:
Mac_Step_1.png
Mac_Step_1.png (9.86 KiB) Viewed 3797 times
Mac_Step_2.png
Mac_Step_2.png (33.24 KiB) Viewed 3797 times
Windows:
Win_Step_2.png
Win_Step_2.png (38.28 KiB) Viewed 3797 times

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();
Infiniti1Up
Posts: 2
Joined: Fri Jan 06, 2017 2:02 am

Re: Redraw issue when adding text fields to UI window

Post by Infiniti1Up »

I noticed this is a bug in Photoshop CC 2015.
CC 2017 seems to have fixed it, but I still wonder if theres a way to keep it backwards compatible for 2015.