×

Discussion Board

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

    Unhappy LWUIT - Redirect form's keyRelese(..) to TextField

    Hi All,

    If my TextField is not focused and my form is in focus, I want my TextField to capture key strokes and put it in the TextField's box as if it was focused. For example, If my focus is on form and I type "abc" using the physical keyboard, I want my TextField to have "abc".

    I am trying to imitate the example below without but without the "floating" TextField:
    http://lwuit.blogspot.ca/2009/09/los...with-text.html

    So I am doing something like this:

    Code:
    	
    public class MessageForm extends BaseForm {
           ....
       
           public void keyPressed(int code) {
    		int key = Display.getInstance().getGameAction(code);
    		
    		if (key > 0) {
    			m_messageList.keyPressed(code);
    		}
    		else {
    			m_replyBox.keyPressed(code);	
    		}
    	}
    	
    	public void keyReleased(int code) {
    		int key = Display.getInstance().getGameAction(code);
    		
    		if (key > 0) {
    			m_messageList.keyReleased(code);
    		}
    		else {
    			m_replyBox.keyReleased(code);
    		}
    		
    	}
           ....
    }
    However, the TextField is not getting anything even though the event is being called. If I just append text to the TextField via setText(...), it would work. The problem is it would also append characters that I don't want (like shift key, sym key, etc.) and I just don't want to filter that as it will just lead to complex scenarios especially with different keyboards. Any ideas?

    Thanks,
    Jim

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    683

    Re: LWUIT - Redirect form's keyRelese(..) to TextField

    Try setting your TextField object to focus (just setting his state and not the real focused item of the form)
    you can do that via m_replyBox.setFocused(true); after you init m_replyBox, they also do that on the example link you gave.
    Heard of DVLUP? Join here

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

    Re: LWUIT - Redirect form's keyRelese(..) to TextField

    After calling the setFocus(true) method on the TextField at the form constructor, the focus is transferred to the TextField and inputs from the qwerty keypad are directed to it. However, if I click another focusable item in the form (like another TextField), focus will be lost from the previously focused TextField and any character that I type won't show up on that TextField anymore. If I call requestFocus() back on that text field, haFocus() will return true - however, the cursor is not on the text field. So can this trick only be achieved if the focus is on the TextField?

    By the way, in LWUIT, does:
    requestFocus() on the TextField == cursor on that TextField
    setFocus(true) on the TextField == cursor on that TextField

    If not, how do I put the cursor back on the TextField after form initialization?

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    683

    Re: LWUIT - Redirect form's keyRelese(..) to TextField

    Quote Originally Posted by lordbritishix1982 View Post
    After calling the setFocus(true) method on the TextField at the form constructor, the focus is transferred to the TextField and inputs from the qwerty keypad are directed to it. However, if I click another focusable item in the form (like another TextField), focus will be lost from the previously focused TextField and any character that I type won't show up on that TextField anymore. If I call requestFocus() back on that text field, haFocus() will return true - however, the cursor is not on the text field. So can this trick only be achieved if the focus is on the TextField?

    By the way, in LWUIT, does:
    requestFocus() on the TextField == cursor on that TextField
    setFocus(true) on the TextField == cursor on that TextField

    If not, how do I put the cursor back on the TextField after form initialization?
    requestFocus() on the TextField == cursor on that TextField, is True
    setFocus(true) on the TextField == cursor on that TextField, is False (it just set the style of the component to be the focused/selected state

    if you want that all of your keys goes just to the one textfield in the form simply make all other components unfocusable using setFocusable(false);
    Heard of DVLUP? Join here

Similar Threads

  1. How to append LWUIT List screen to a LWUIT Form in j2me?
    By pavanragi in forum Mobile Java General
    Replies: 1
    Last Post: 2012-08-06, 07:01
  2. LWUIT TextField - Removing InputModeOrder Text "Abc" from TextField
    By vishal.vpb in forum Mobile Java General
    Replies: 1
    Last Post: 2011-11-14, 06:29
  3. LWUIT TextField..?
    By kumar1234567 in forum Mobile Java General
    Replies: 5
    Last Post: 2011-08-04, 08:47
  4. pass Text field value from one form to another form in LWUIT.
    By debasish_cse05 in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2011-01-13, 11:21
  5. problem in back and forth of LWUIT form and normal form in j2me
    By jugal.inani in forum Mobile Java General
    Replies: 8
    Last Post: 2010-06-09, 12:24

Posting Permissions

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