These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

set focus on last selected item

DianaL
Registered: Nov 17 2009
Posts: 80

Hi Guys,

my next question is:

is it possible to set focus on the last items of a populated list with xfa.host.setFocus(PAGE3.lisbox1.selectedIndex); ?

Thanks in advance!!

Diana

radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
You can use the setItemState property for this task.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

DianaL
Registered: Nov 17 2009
Posts: 80
ok, thanks!!

I ll try this one.

Diana
DianaL
Registered: Nov 17 2009
Posts: 80
I need your help!!!

I tried this code, but somehow it doesnt work.

var lst = Listbox1.rawValue;
if (Listbox1 && Listbox1.selectedIndex > -1){
xfa.host.setFocus(Listbox1.setItemState(Listbox1.ListCount - 1) = true);
}

the reason why I am doing setFocus is, because when the Listbox1 gets populated the visible area is limited and the scrollbar appears only if you click on the listbox.

But the user should be able to see automatically when the amount of items exceed the listbox by focusing on the last selected/ added item.

Please help me on this!!!!

Thank you in advance!!

Diana
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Hi,

you can do this the following way.

To preselect the last item in the list box use this script in the enter:event.
this.setItemState(this.length -1,1);

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

DianaL
Registered: Nov 17 2009
Posts: 80
Hi,
thanks for the code!!

unfortuantely, it's not working!! i also tried to set focus on the list where the items are populated with this code but nothing happens. the last populated items is not highlighted/ selected.
what can I do??

I appreciate your help!!

Diana
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Try it in the mouseEnter:event.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

DianaL
Registered: Nov 17 2009
Posts: 80
Nope it doesnt work in mouse enter or initialize or any other events...

maybe this code is not appliable to my listbox, what do you think?
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Sure it is...check out this sample
[url]https://acrobat.com/#d=cP2aKJRv34MuDdqK50jYkg[/url]

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

DianaL
Registered: Nov 17 2009
Posts: 80
here is my listbox, i did what you said but it's not working. could you please verify it?


https://acrobat.com/#d=l0mujTOFduSJFele5R5i3g

Thank you so much!!!

Diana
radzmar
Expert
Registered: Nov 3 2008
Posts: 1202
Sorry, I cannot download your file.
Please check the settings.

radzmar
LoveCycle Blog
Documents you need:
LiveCycle Designer ES2 Docs

DianaL
Registered: Nov 17 2009
Posts: 80
I am sorry, I published this now.

Please let me know if you still can not access it.

https://acrobat.com/#d=l0mujTOFduSJFele5R5i3g

Thank you!!!

Diana
DianaL
Registered: Nov 17 2009
Posts: 80
hi,

your code is apparently only working for single selection listboxes.

Thanks,
Diana