Expand my Community achievements bar.

Javascript to setFocus to nothing (as if none of the fields/buttons on a page have the focus)

Avatar

Level 3

Still trying to find a fully functional work around from my initial post here: mouseEnter/mouseExit event is triggering a screen jump ONLY when zoomed in?

Thanks again to Radzmar for his thoughts.

Part of the solution is clearing the focus using Javascript. --- as if the end-user clicked on dead space of the form so none of the fields, buttons, etc. has focus.

Documentation states:

      xfa.host.setFocus() or xfa.host.setFocus(null) should do the trick.  But this only seems to work sporadically.  For example:

          1) Called from the mouseEnter event OF A BUTTON, either script WILL clear the focus from a traditional field object (text/numeric/etc.) --- but, ironically, NOT from a button.

          2) Exact same code in the exitEvent of a normal text field will NOT clear the focus. So while setFocus to an actual location WILL override the TAB order, setting to (null) or () doesn't do anything.

Am I insane or is there really no way to just simply clear the form's focus?

Thanks,

BR

6 Replies

Avatar

Level 10

Hi there, I've tried the function xfa.host.setFocus(); with no parameter and it is working for me...

I've also tried it on the mouseEnter event of a button and it works fine.

Avatar

Level 3

Hi Magus,

Thanks for the reply; sorry for the delay -- wanted to construct a working example to post. Link is: Shared Files - Acrobat.com

I'll test the link to make sure it works.

It shows the varying conditions of when the codes xfa.host.setFocus() or xfa.host.setFocus(null) will or will not work WHEN THE CODE IS IN THE MOUSE ENTER EVENT.

There appears to be a correlation between "classname" & "ui.oneOfChild.classname" as to whether or not it will work. For example:

     1) code in the mouseEnter event of a text field will:

          -  NOT clear the focus from another text field, numeric field, or decimal field.

          -  BUT it WILL clear the focus from a date field, drop down, check box, button and radio group.

I'm a newbie at this still.  Wiser minds have any ideas?

Is there really no code to place in the mouseEnter event of all objects (that have a mouseEnter event) to set the focus to null?

BR

Avatar

Level 3

Magus - posted to the full discussion rather than reply directly to you.  Sorry!

Avatar

Level 7

Did anyone figure this out? I am trying to setFocus(null) from a mouseDown event, and it doesn't work! setFocus to another form object, does, however.

Avatar

Level 1

I need an answer for this too - this is a serious problem. Scripts of fields with activate/deactivate event do only run again if you clear the the focus to them, thats a catastrophe.

Avatar

Level 10

Hi,

I'm not sure exactly what the effect you are after, but you can setFocus to a field that is set to Visible (Print Only), which might do what you want, there would be no visible indication of what has focus.

You can also execute events with the execEvent method, so TextField1.execEvent("enter") will run the enter event of TextField1

Regards

Bruce