• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

change combobox property using personal format action

Explorer ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

Hello,

I have a combobox that is not modifiable so the user can easily navigate through the list by pressing the first caracter.

This combobox contains an element that should set the combobox property as modifiable ("Other please specity").

 

I have manage to code the event so it change the property of the combobox but it won't actually change he property until it lose the focus. So i am force to set the focus to another field for it to work.

 

p.s: i tried setting the focus on the other field and then back to the combobox and it won't change the property either.

 

	var liste = getFunctionList();
	var value_idx = liste.indexOf(event.change);
	if (event.willCommit == false) {
		if (value_idx == -1) {
		
		}
		else if (value_idx == liste.length -1) {
			event.target.editable = true;
			getField("1.1f.Unite").setFocus();
		}
		else if ( value_idx < liste.length -2 )  {
			event.target.editable = false;
			getField("1.1f.Unite").setFocus();			
		}

	}

 Is there an event or a way that would allow me to set the combobox as modifiable when the last item is selected else set it as non modifiable without having to quit the combobox?

 

Thanks

TOPICS
Acrobat SDK and JavaScript

Views

512

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

This is such an easy thing to do with LiveCycle but Acrobat pro seems to be missing many feature like such.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

Is the combobox set to "Commit value immediately"?  This property is on the "Options" tab of the field properties.

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

Hello Thom,

No it wasn't checked, but if I check the option the focus still goes out.
I tried ot add a new statement in the function to give it back the focus if the user select Other please specity but still the focus doesn't return after the commit.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

You're trying to do something tricky with the PDF form here. So you have to be careful. It's possible the focus problem is related to the context of the script.  If this is in a calculate or keystroke event, then the value of the field is uncommitted at that time. Focus is a UI property that cannot be valid until after the value is committed. I'm not even sure a field can set it's own focus from a script in itself.

So, I'd suggest changing the context of the action. First, move your code to a post commit action, such as the format script, so you know that everything is happening after the field value has officially changed. Then only set focus to the other field. In the OnFocus event of the other field, immediately set focus back to the combobox. This puts the context of the set focus completely outside of the field, and after the value of the field is settled.

Another technique is to use a timer, but I think the focus bounce back is cleaner. 

 

Also, be aware that these techniques will only work for the desktop Acrobat/Reader. I doubt they will work on any other PDF viewer or on mobile. 

 

There is another way to go with this. Make the dropdown editable all the time. 

 

 

 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

Thanks for the help Thom, 

Unfortunately if i set the onFocus event of the other field to move the focus back to my combobox that would cause a problem when the user want to fill that other field by clicking it or using the tab to focus on it it would return the focus to the combobix.

 

I already spent way to much time on this tiny functionnality, i will do as it was before / you suggest and just set it to modificable.

 

Thanks again for you help 

 

Yan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 31, 2020 Mar 31, 2020

Copy link to clipboard

Copied

It's easy to go down these rat holes trying to go outside the natural AcroForms functionality.  But it's also instructive. 

Just as a note, there are ways to mitigate the focus bounce back on the other field. For example using a document level state variable, so the bounce back only happens the variable is set, or using adding a field just for this purpose, one the user can't see or interact with.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 31, 2020 Mar 31, 2020

Copy link to clipboard

Copied

LATEST

Everything you say is true. 
Sometime the answer is right under your nose 'as using a global / document level variable'. 

Yet i just keep digging and digging because you know there as to be a easy "non hack" way to do it.

 

Ohh well, i'll keep your suggestion to use document level variable in mind for next time.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines