The Source for Java Technology Collaboration

Home » java.net Forums » Mobile & Embedded » LWUIT

Thread: List and focus issue

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 8 - Last Post: Nov 20, 2008 1:09 AM by: Shai Almog
anvka

Posts: 4
List and focus issue
Posted: Aug 21, 2008 12:30 AM
 
  Click to reply to this thread Reply

Hi,

I have a form containing a list with some items. When an user presses the "FIRE" button to select an item, a new form is shown. So far so good, but when the user presses the back key to display the old form it seems that the pressed listitem is already selected thus requiring an additional press of the "FIRE" button before one can scroll up and down in the list.

I have done some research and found some suggestions of which none have worked. I've tried to "requestFocus" upon returning to the first form, with no result and I've also tried to "revalidate" the parent, also without results.

Is there something obvious that I'm missing?

Thanks!

Shai Almog
Re: List and focus issue
Posted: Aug 21, 2008 12:50 AM   in response to: anvka
  Click to reply to this thread Reply

Hi,
revalidate won't work. Did you try requestFocus() on the list or on
the Form component?
You should invoke requestFocus() on the list itself for this to work
correctly.

Also make sure the form is completely constructed and the list is
added to the parent form.

> Hi,
>
> I have a form containing a list with some items. When an user
> presses the "FIRE" button to select an item, a new form is shown.
> So far so good, but when the user presses the back key to display
> the old form it seems that the pressed listitem is already selected
> thus requiring an additional press of the "FIRE" button before one
> can scroll up and down in the list.
>
> I have done some research and found some suggestions of which none
> have worked. I've tried to "requestFocus" upon returning to the
> first form, with no result and I've also tried to "revalidate" the
> parent, also without results.
>
> Is there something obvious that I'm missing?
>
> Thanks!
> [Message sent by forum member 'anvka' (anvka)]
>
> http://forums.java.net/jive/thread.jspa?messageID=294541
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


anvka

Posts: 4
Re: List and focus issue
Posted: Aug 21, 2008 1:31 AM   in response to: Shai Almog
 
  Click to reply to this thread Reply

Hi,

I tried to requestFocus() with both form and list in various combinations :)

I'm a bit unsure of what you mean. All forms and components are constructed during the startup of the MIDlet. I then utilize form.show() to navigate between forms.

For example, when an user starts the MIDlet all forms and various components are constructed and added to correct parents. The user then arrives to form1 containing a list. When an user presses a listitem, the MIDlet calls form2.show and thus replacing form1 in the gui. When the user presses "BACK" the MIDlet calls form1.show() replacing form2 in the gui. Now the user must first press "FIRE" to be able to navigate in the list.

I've tried to call both form1.requestFocus() and list.requestFocus() before form1.show() and also after form1.show() but it doesn't seem to work.

Also, only "FIRE" works when enabling the list. "UP" and "DOWN" won't work until "FIRE" is pressed.

Shai Almog
Re: List and focus issue
Posted: Aug 21, 2008 2:22 AM   in response to: anvka
  Click to reply to this thread Reply

> I've tried to call both form1.requestFocus() and list.requestFocus
> () before form1.show() and also after form1.show() but it doesn't
> seem to work.

I hope you aren't doing both since they (obviously) negate each other.

If this still doesn't work for you try invoking list.setHandlesFocus
(true) upon returning.

> [Message sent by forum member 'anvka' (anvka)]
>
> http://forums.java.net/jive/thread.jspa?messageID=294557
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]


anvka

Posts: 4
Re: List and focus issue
Posted: Aug 21, 2008 2:46 AM   in response to: Shai Almog
 
  Click to reply to this thread Reply

Hehe, sorry, was a bit unclear - what I meant to say was that I've tried both but not at the same time :)

I don't seem to find list.setHandlesFocus, only list.setHandlesInput. I'm using the code from 20080814.

anvka

Posts: 4
Re: List and focus issue
Posted: Aug 21, 2008 2:48 AM   in response to: anvka
 
  Click to reply to this thread Reply

Awesome!

list.setHandlesInput(true) fixed my problem! Thanks for the help!

pablofer72

Posts: 1
Re: List and focus issue
Posted: Nov 18, 2008 2:33 PM   in response to: anvka
 
  Click to reply to this thread Reply

This works for me too!

I was having the exact same problem, too.
Thanks a lot, guys!

mrjansa

Posts: 36
Re: List and focus issue
Posted: Nov 19, 2008 1:35 AM   in response to: anvka
 
  Click to reply to this thread Reply

Anvka says he constructs all the forms during the startup, and then just calls form.show() to navigate back and forward thru the forms. Is this really the best way to handle form navigation Shai?
Why I wonder is because we are converting our J2ME application into using LWUIT, and we want to know how to handle form navigation the best way.

Shai Almog
Re: List and focus issue
Posted: Nov 20, 2008 1:09 AM   in response to: mrjansa
  Click to reply to this thread Reply

Thats reasonable,
we usually create forms on the fly to allow GC as much room as possible.

> Anvka says he constructs all the forms during the startup, and then
> just calls form.show() to navigate back and forward thru the forms.
> Is this really the best way to handle form navigation Shai?
> Why I wonder is because we are converting our J2ME application into
> using LWUIT, and we want to know how to handle form navigation the
> best way.
> [Message sent by forum member 'mrjansa' (mrjansa)]
>
> http://forums.java.net/jive/thread.jspa?messageID=317543
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

Shai Almog
http://lwuit.blogspot.com/

[att1.html]





 XML java.net RSS