Copy link to clipboard
Copied
Hello all,
I'm attempting to write a script that enters text into an Acrobat field via Javascript but prevents additional text from being entered once it hits the field bounds. My problem is, unlike when entering text manually, the fieldFull keystroke event property is not triggered when populating a field via Javascript. Here's an example below:
var f.addField('name', 'text', 0, [0, 200, 200, 0]);
f.multiline = false;
f.doNotScroll = true;
f.textSize = 36;
f.setAction('Keystroke', 'app.alert(event.fieldFull)');
var contents = 'I am a sentence.';
for (var i = 0; i < contents.length; i++) {
f.value += contents[i];
}
The listener detects the keystrokes just fine, but for whatever reason event.fieldFull is returning false regardless of whether the text is outside the field bounds (aaand the script continues to enter text despite the fact that doNotScroll is enabled).
Any reason why this is or any possible workarounds? Thanks in advance! 🙂
There are two types of keystroke event, commited and uncommitted. you need to use the "event.willCommit" property to differenciate them. "event.fieldFull" is only valid for the uncommitted event. which only happens when the user is actually typing into the field.
That's just the way it works. This functionality was never very useful. You can find posts from almost 20 years ago where people are complaining about the same (or similar) thing.
Put a character limit on the field.
Copy link to clipboard
Copied
There are two types of keystroke event, commited and uncommitted. you need to use the "event.willCommit" property to differenciate them. "event.fieldFull" is only valid for the uncommitted event. which only happens when the user is actually typing into the field.
That's just the way it works. This functionality was never very useful. You can find posts from almost 20 years ago where people are complaining about the same (or similar) thing.
Put a character limit on the field.
Copy link to clipboard
Copied
Bummer, I was hoping this wasn't the case. Thanks for the response—appreciate the explanation.