[javascript] bug? app.execDialog() erratic result from dialog.store() for 'edit_text'

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: Daniel - PDF-XChange, PDF-XChange Support, Vasyl - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

Post Reply
Mathew
User
Posts: 564
Joined: Thu Jun 19, 2014 7:30 pm

[javascript] bug? app.execDialog() erratic result from dialog.store() for 'edit_text'

Post by Mathew »

When using an edit_text box with PopupEdit: true the information provided to the change event is erratic. Sometimes it provides the most recent change, but sometimes it doesn't update. Sometimes the change event happens twice for one change, sometimes once.

To reproduce:

Code: Select all

// test of input box

{
    const inputTest = {
        initialize() {
        },
        commit() {
        },
        txB1(dialog) {
            console.println( JSON.stringify( dialog.store()));
        },
        description: {
            name: "Edit text box", // Dialog box title
            elements:
            [{  type: 'edit_text', width: 300, item_id: 'txB1', PopupEdit: true
            },
            {   type: 'ok'}
            ]
        }
    };
    
    app.execDialog(inputTest);
}
The text box is already selected, so start typing 12345 then use backspace to delete the numbers one at a time, the console shows:

Code: Select all

{"txB1":""}
{"txB1":""}   // text box actually contains 1
{"txB1":"1"}
{"txB1":"12"} // it caught up to 12
{"txB1":"12"}
{"txB1":"123"}
{"txB1":"123"}
{"txB1":"1234"}
{"txB1":"1234"}
{"txB1":"12345"} // 12345 (it stayed caught up, the event happening twice for each keystroke with the data provided first the value before the keystroke, then after)
{"txB1":"12345"} // 1234 (deleting it's showing the old data and only firing the change event once)
{"txB1":"1234"} // 123
{"txB1":"123"} // 12
{"txB1":"12"} // 1
{"txB1":"1"} // empty 
It's quite erratic. Sometimes it gets the most recent change, sometimes it doesn't.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19794
Joined: Mon Jan 12, 2009 8:07 am
Contact:

Re: [javascript] bug? app.execDialog() erratic result from dialog.store() for 'edit_text'

Post by Stefan - PDF-XChange »

Hello Mathew,

Thanks for reporting this! I've asked a colleague working on the JS engine to take a look here and advise.

P.S. Our devs just confirmed that they are already working on this. So I expect the fix to be in the next build, but will await their confirmation before stating it with certainty :)

Kind regards,
Stefan
Post Reply