Planet PDF Forum Planet PDF Forum
  New Posts New Posts RSS Feed - Currently active field?
  FAQ FAQ  Forum Search   Register Register  Login Login


Hi, welcome to the Foxit Planet PDF Forum. If you have PDF or Adobe Acrobat questions then the right place to ask them is here, in this forum.

Currently active field?

 Post Reply Post Reply
Author
jhmcmullen View Drop Down
New Member
New Member


Joined: 07 Apr 2016
Location: Canada
Points: 5
Post Options Post Options   Quote jhmcmullen Quote  Post ReplyReply Direct Link To This Post Topic: Currently active field?
    Posted: 07 Apr 2016 at 4:08pm
Hi, all. First post but I've read the forum for years off and on, but I'm still underserved in the knowledge area.

Context:

At the new job, one of my tasks is to prep software-generated forms for release. Specifically, I have to make text fields into date fields. (There are other kinds of fields, and other kinds of text fields, even.) 

So for any document, I don't know if there are text fields that should be date fields. I'm okay with opening them up, because I have to for other tasks, but I find the process of formatting a field to be somewhat tedious and lengthy. 

I have Acrobat X Pro. (Getting a different version is not an option.)

I want to:

Have a small dropdown menu or toolbar button that lets me apply the set of properties to the field that I need with one or three mouseclicks, so I don't have to wait for Acrobat to bring up the properties dialog, to switch tabs, to present the list, and so on.

I have looked at the Action wizard and it doesn't look like it does what I want in this version of Acrobat.

Use case

My thought is that I can select the field I want to change, right click to get the context menu (or have a button on the toolbar) and then click the entry or button to apply all the changes.

In the code to apply the changes, I'll make sure that the field involved is a text field and then make it a Date field by setting the field value to a Date() with the correct format.

Presumably this will be a user level script, and maybe I'll include some button to turn it on and off so it's not on all the time.

Questions

Which is easier, inserting into the existing context menu, a dropdown menu that's activated some way, or a button on a toolbar? None of those are areas I've worked in.

Is there a way to get the currently active field? I think the information is contained in the event structure (event.target) so I suppose I could select the field, search for the appropriate event, and suck it out of event.target. 
  - If using a toolbar button, it's whatever field just lost focus except that I'll have to avoid other fields. Doable.

I am right about how you set the Date format, right?

I know that's a lot of questions and I have no cred here, but I hope you'll help.

If there's an existing thread or example that will do it or something close, just point me there.
Back to Top
Sponsored Links


Back to Top
jhmcmullen View Drop Down
New Member
New Member


Joined: 07 Apr 2016
Location: Canada
Points: 5
Post Options Post Options   Quote jhmcmullen Quote  Post ReplyReply Direct Link To This Post Posted: 07 Apr 2016 at 9:53pm
Well, poking around some more revealed one error to me. Using printd() just prints the current date into the field; it doesn't change the format as it is presented in Acrobat. Presumably choosing the list item on the Format menu sets a script to be run when the Format stage of event processing is hit (if I'm even saying that right) and the Acrobat program recognizes certain types of formats already. That makes it uglier.
Back to Top
jhmcmullen View Drop Down
New Member
New Member


Joined: 07 Apr 2016
Location: Canada
Points: 5
Post Options Post Options   Quote jhmcmullen Quote  Post ReplyReply Direct Link To This Post Posted: 07 Apr 2016 at 10:39pm
Got a bit farther. This article (http://khkonsulting.com/2015/09/apply-standard-pdf-form-field-formattingkeystrokevalidation-events-to-fields-via-javascript/) took me through the formatting part. I can now make an arbitrary text field into the proper kind of Date field.

The user interface is going to be a hassle, though, because I saw elsewhere that the ability to put up a toolbar was removed after Acrobat Pro 9. Still, a popup menu (popUpMenuEx() probably) will be sufficient. All I have to do is figure out what triggers it, and mouse entry would be sufficient. So, something like...

// some kind of toggle to enable

// at a document or Page level, look at every Field event
// If MouseEnter, get the field 
//    If the field type is text, pop up the menu
//        If the result is yes, apply AFDate_Format() and AFDate_Keystroke actions to the field
//    Otherwise do nothing

The next challenges will be figuring out what the toggle will be (because I don't want the menu appearing every time my mouse goes into a text field) and figuring out how we look at every event without modifying the fields in general.
Back to Top
jhmcmullen View Drop Down
New Member
New Member


Joined: 07 Apr 2016
Location: Canada
Points: 5
Post Options Post Options   Quote jhmcmullen Quote  Post ReplyReply Direct Link To This Post Posted: 08 Apr 2016 at 5:40pm
Just noticed this is a forum for forms and FDF, and I don't see FDF as in the scope of my problem. Sorry for posting in the wrong place. I'll re-post elsewhere.
Back to Top
gkaiseril View Drop Down
Senior Member
Senior Member


Joined: 15 Jul 2011
Location: USA
Points: 4076
Post Options Post Options   Quote gkaiseril Quote  Post ReplyReply Direct Link To This Post Posted: 09 Apr 2016 at 4:13pm
You can specify the format for the date display in the util.printd method and the AFDate_Format function. You may also want to add some custom formatting and validating scripts so only valid dates can be entered. When one uses the provide UI in Acrobat all of this done as part of the formatting screen processing.

If I need a lot of control over form fields when creating a form, I work with Apache OpenOffice.org and create all the form fields there along with adding various layout an 0ptions for the fields. I can then export the form and fields to a PDF. Libre Office also has this capability/


Edited by gkaiseril - 09 Apr 2016 at 4:15pm
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.10
Copyright ©2001-2017 Web Wiz Ltd.

This page was generated in 0.047 seconds.