Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 42
Registered: ‎02-11-2014
My Device: Q10, Z10, Z30, Passport, Classic
My Carrier: None

TextField / on screen keyboard / focus questions

I'm writing a native/cascades app that has several screens that each show several TextFields.

 

When I run on the Z10 simulator and click the TextFields, the onscreen keyboard does not show.

I need to swipe up from the bottom to make the onscreen keyboard show.

Is there a way to make the keyboard automatically show when the TextField is clicked, like on the real hardware?

I'd like this so that I don't accidentally let a screen slip through that doesn't resize properly when the onscreen keyboard shows up.

 

When I'm editing a TextField, and then press Enter (onscreen keyboard or PC keyboard), the next TextField automatically gains focus.

UNLESS, it's the last TextField.  In that case the last TextField looses focus and nothing gains it.

Is there a way to make the first TextField gain focus after the last one looses it?

 

As per below, I added a KeyListener to the last TextField that makes the Enter key "wrap" the focus back to the first TextField, but the keyboard still dissapears.  Is there a way to tell QML that I've handled the KeyEvent, and stop it from bubbling up the chain?  Maybe this would prevent whatever is hiding the keyboard from running?

QML code on last TextField:

onKeyPressed:

{

    if (event.key == 13)

    {

        firstTextFieldID.requestFocus();

        event.accept();    // Error

        event.accept = true;    // Error

        // How else to tell QML I've consumed the event?

    }

}

 

As a side note, I have "import bb.cascades 1.2" at the top of the QML file.  Is there some key definition for "Key.TAB" or something I can use instead of "13"?

 

I'd like the TAB key to work the same way (mostly as a convienence when I running on the simulator, since I don't see a TAB key on the onscreen keyboard anywhere...  Maybe I've overlooked it?)  I added a KeyListener to each TextField to make this work.  But is there an easier way?  I didn't need to do this for the Enter key to change focus among the TextFields.

 

Thanks,

Ed

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: TextField / on screen keyboard / focus questions

Unfortunately I still can't get my simultor to work but if I remember correctly the keyboard should show as it does on the real hardware so not sure why it's not for you.

 

On the focus question you can check for a lost focus  signal on the last TextField then set the focus back to the first one...

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__textfield.html#function-focu...

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__control.html#function-reques...


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.