Expand my Community achievements bar.

Programmatically attach event-handler to multiple controls

Avatar

Level 4

Hello folks,

I was wondering if it's possible to attach an event-handler to multiple controls at run-time in LiveCycle.

For example, attaching my event-handler function to all of the textfields objects on the form.

Do you know how?

Thank you,

Yair Nevet

5 Replies

Avatar

Level 10

Hi Yair,

Event handlers is Flex/Flash methods. I'm trying to understand what you are trying to achieve in LC Designer.

You can use the calculate event to keep track on different objects. So that if the value of one object changes, all other objects that reference that object will see the change and take appropriate action based on the script.

Another option is to create a function in a script object. This keeps the script in one location, but it can be accessed by / fired from any object.

Can you describe exactly what you are trying to achieve?

Niall

Avatar

Level 4

Hi Niall,

Imagine a loop in the form:ready event that go through several TextField objects and defining their change event by associating script to them.

Here is a pseudocode example:

for(var i = 0; i < TextFields.Collection.Length; i++)

     TextFields.Collection[i].change = function(){

          xfa.host.messageBox("You changed me!");

}

Now, all of the textfield objects in my form associated the following script in their change event:

xfa.host.messageBox("You changed me!");

I hope it's clear enough,

Thank you

Avatar

Level 10

Hi Yair,

There is a good thread here that may help: Can you define an event programmatically?

I think the listen property may be the best option.

Niall

Avatar

Former Community Member

On a possible related sidenote, there are xfa javascript methods for getting and setting an xfa object's "delta function". I never understood what a delta function is, and the documentation is vague at best.

Avatar

Level 10

Hi,

As far as I know the delta relates to restoring an object manually, instead of using the "automatically preserve script changes" in the File > Form Properties > Default tab.

Stefan Cameron has a post here: http://forms.stefcameron.com/2008/09/29/restoring-the-state-of-your-form/

From memory I tried it on one form, but generally would tend to stick with the automatic formstate.

Good luck,

Niall

Assure Dynamics