Skip to main content
Legend
September 23, 2025
Question

Bug - Extendscript editnumber control autorounds with workaround

  • September 23, 2025
  • 1 reply
  • 95 views

I've found a bug with the Extendscript editnumber control and a workaround. Please see my related post in the Bridge forum, the bug is slightly different. Tested on macOS PS 26.10 and Windows 10 Pro PS 25.12.4.

 

When a decimal number is entered into an editnumber control (in an Extendscript window), the decimal is incorrectly rounded to two decimal places. If the script requires more precision, there is a workaround. Please see the posted snippet.

 

To test, type in a number such as 0.00255. Without the workaround code, this is rounded to 0. With the workaround, the typed value is retained.

 

/*
This is a test snippet to demonstrate editnumber bugs in Photoshop.
Editnumber entry is autorounded to two decimal places.
This can be worked around with the code below.
*/
test();

function test(){
    try{
        var weight = '';
        rnWindow = new Window ('dialog', 'Editnumber Test', undefined, {closeButton:true});
        rnPanel = rnWindow.add('panel', [0, 0, 650, 540], '');
        rnPanel.num1 = rnPanel.add('editnumber {justify:"left"}', undefined, 0);
        rnPanel.num1.minimumSize  = [90, 20];
        rnPanel.button1 = rnPanel.add('button', undefined, 'Display');
        rnPanel.button2 = rnPanel.add('button', undefined, 'Close');
//workaround
        rnPanel.num1.onChanging = function(){
            weight = rnPanel.num1.value.toString();
            }
        rnPanel.num1.onDeactivate = function(){
            rnPanel.num1.value = eval(weight);
            rnPanel.num1.text = weight;
            }
//end workaround
        rnPanel.button1.onClick = function(){
            Window.alert(weight + '\r' + rnPanel.num1.value.toString());
            }
        rnPanel.button2.onClick = function(){
            rnWindow.close();
            }
        rnWindow.layout.layout(true);
        rnWindow.show();
        }
    catch(e){
        Window.alert(e + ' ' + e.line);
        }
    }

 

1 reply

Stephen Marsh
Community Expert
Community Expert
September 23, 2025

Thank you for sharing, I usually only use editnumber for integers.

ExUSAAuthor
Legend
September 24, 2025

Yeah I'm not sure if its supposed to be for integers or a fixed number of decimals or what, documentation is lacking. I was getting odd results in a script and this is why.