×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    41

    Angry LWUIT - Preventing textbox from loosing focus if a component is added to a container

    Hi All,

    I have a form that has a container which is subclassed to become a list and a text box at the bottom of the form (think of a chat application). I do not use List because each cell can be variable in height. I looked at ContainerList too but it does not do well with adding or removing items on the fly.

    Anyway, whenever I type some text into the textbox and I press the confirm button, I create a label which gets added into the container. The problem is that everytime I do this, the focus on the textbox where I typed the message is lost and is probably transferred to the container (or the cell that I just added) and I do not want this to happen because this will slow down text entry a lot. Is there anyway that I can prevent this behavior from happening?

    Many thanks,
    Jim

  2. #2
    Regular Contributor
    Join Date
    Dec 2012
    Location
    India
    Posts
    271

    Re: LWUIT - Preventing textbox from loosing focus if a component is added to a contai

    Why use label ? Are you not getting issues when the line scrolls multiple lines ?

    Try adding a text area with UIID as label instead.You can add a focuslistener to it and inside the focus gained method,request focus for your textbox.

  3. #3
    Registered User
    Join Date
    Feb 2013
    Posts
    41

    Re: LWUIT - Preventing textbox from loosing focus if a component is added to a contai

    My bad - I am actually using a textbox. I did try overriding the focus gain method to set the focus back to the text box but it does not work and focus does not transfer back to the textbox:

    Code:
    protected void focusGained() {
       m_form.getReplyBox().requestFocus();
    }
    The code above is also running on EDT so it should be fine form that perspective. Also, for some reason, requestFocus() doesn't really seem to work for me. Whenever I call requestFocus() on text boxes (on EDT), it does not seem to show the VKB. Perhaps the focus is being stolen by other events? I really don't know..

    Anyway, even if that code were to work, won't you see a bit of wiggling when the focus is transferred back to the reply box because the vkb needs to go back up again? What I am looking for is a way to completely prevent the focus from being lost when adding components to the container. One of my ideas include prepopulating the container with text boxes and just set the data for each of the text box as they come.. but there must be a simpler way than that

  4. #4
    Registered User
    Join Date
    Mar 2013
    Location
    Nasik, India
    Posts
    21

    Re: LWUIT - Preventing textbox from loosing focus if a component is added to a contai

    Hi lordbritishix1982,

    prepopulating entire container will terribly slow down the performance of the app. (Think of worst case lower end devices).
    Instead you can just set the focus to textbox by using focusing methods (e.g. txtArea.setFocus(), Form.setFocused(txtArea).

    Further VKB can be turned on off accordingly if needed. (AFAIK vkb gets displayed only if user press any key when textarea is focused)

  5. #5
    Registered User
    Join Date
    Feb 2013
    Posts
    41

    Re: LWUIT - Preventing textbox from loosing focus if a component is added to a contai

    I limit the rows to just 25 at any given time so performance is not that bad with that solution. With your suggestion, wouldn't it demonstrate a behavior similar to my reply? The sequence is:

    1. Click on text box, VKB shows up
    2. Type text and hit send, focus is lost on text box and transferred to the newly added component and VKB goes down
    3. On that new component, request focus back to text box. Focus gets transferred back to text box and VKB goes up again.

    So between steps 2 and 3, you'll probably see the VKB briefly go down and then up. Also, requestFocus does not seem to work for me. Everytime I call requestFocus to a text box, it does not transfer the cursor to the textbox.

Similar Threads

  1. How to get the Focus textbox data
    By J2meDeveloper in forum Mobile Java General
    Replies: 5
    Last Post: 2009-09-07, 06:38
  2. How to dispose the Form object which is added to Display / Container ?
    By neeraja.nokia in forum Mobile Java General
    Replies: 5
    Last Post: 2009-01-29, 18:01
  3. component focus
    By neeraja.nokia in forum Mobile Java General
    Replies: 4
    Last Post: 2008-12-08, 07:02
  4. Tabs disappear after loosing focus
    By Vincenco2 in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-01-31, 13:08
  5. Application gaining/loosing focus?
    By chishti.hameed in forum Symbian
    Replies: 1
    Last Post: 2005-07-20, 17:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×