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

How to programmatically focus a field in a dialog?

Explorer ,
Jan 30, 2018 Jan 30, 2018

I don't see a focus() method documented under the dialog documentation but when I inspect the dialog keys I see that one of them is ​focus​. Is there a way to accomplish this?

TOPICS
Acrobat SDK and JavaScript , Windows
1.2K
Translate
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 ,
Jan 30, 2018 Jan 30, 2018

Where did you see that?

Translate
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 ,
Jan 30, 2018 Jan 30, 2018

Yes, there is an undocumented Focus function in the runtime dialog object.  Its input is the item_id of target field.

There are many undocumented functions, properties, and options for the dialog object.  Some are undocumented because they are incomplete, or never worked out. But for some it's just like Adobe just decided scripting wasn't important and stopped development/support. Documenting something means you have to support it.

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

Translate
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 ,
Jan 30, 2018 Jan 30, 2018

Yeah, I'm aware of many of these functions (like the image loading one), but wasn't aware of the focus option, except for the first_tab parameter. Neat.

Translate
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 ,
Jan 30, 2018 Jan 30, 2018

I tried doing dialog.docus("myid"); but it doesn't seem to work. I am trying to focus the field they just left if the validation failed. But maybe I shouldn't use this function since it's not supported. So far using undocumented features has not been promising. I tried using a multi-column list view which worked great on Acrobat on Mac but then when I tested on Windows it completely slowed down Acrobat and it constantly froze so I had to switch it back to a regular list view.

Translate
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 ,
Jan 30, 2018 Jan 30, 2018

you do know it's spelled "focus" not "docus"

The function does work, but it's going to have problems if it's used in a transition state. So what do you mean by "validation". Do you mean the "validate" function that is called before the dialog exits, or is a text field item_id function?  I've only use this function before on a button function.  It worked fine. But if the user is tabbing or clicking onto another field there are a few different things going on and it may not work as well.

Are there any errors reported:

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

Translate
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 ,
Jan 30, 2018 Jan 30, 2018

Haha yes, I meant "focus", sorry. It's called in an item_id function. No errors.

Translate
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 ,
Jan 30, 2018 Jan 30, 2018

Well then unfortunately it's probably not going to work the way you want   Too bad, because that's a perfect use for it.

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

Translate
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 ,
Jan 31, 2018 Jan 31, 2018

Is there any documentation on undocumented functions?


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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 ,
Jan 31, 2018 Jan 31, 2018

Sure. It's available in a book written in Ancient Sanskrit, sold only by Blockbuster.

Translate
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 ,
Jan 31, 2018 Jan 31, 2018
LATEST

Ha ha, I've got a list I've collected.  But half of it doesn't work, either because I don't know the real usage or inputs, or because it never worked.   Here's one I never figured out, and Joel just brought up the other day, "field.doAction()".  Where field is a regular form field.

There have always been undocumented functions and properties shown in examples in the Acrobat JS Ref. For example Matrix2D is undocumented, but it's used in the "doc.addLink()" sample.

There are also lots of undocumented functions and properties used in the old folder level JS files that installed in previous versions of Acrobat. If you can get a hold of these, they are a gold mine.

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

Translate
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