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
New Developer
Posts: 41
Registered: ‎08-02-2014
My Device: BlackBerry Z10
My Carrier: Wind Mobile

requestFocus() doesn't stick

Hey developers! I created a Sheet checking to see if the password that the user entered was correct or not. If not correct, an error message is shown.

I'm using requestFocus() on a textfield. It's called when the Sheet is onOpened(). But when the error message is shown, the virtual keyboard hides.

Is there any way to keep the keyboard opened at all times? I don't know why the virtual keyboard hides when the error message is shown.

Hope this makes sense. If you're confused, I can post some code.

New Developer
Posts: 41
Registered: ‎08-02-2014
My Device: BlackBerry Z10
My Carrier: Wind Mobile

Re: requestFocus() doesn't stick

Actually, I think I know why the virtual keyboard hides (if you tap outside of the textfield or tap on the Submit button).

Developer
Posts: 1,668
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: requestFocus() doesn't stick

how are you showing your error message ?

Toast ? Dialog ?

 

you should place your request focus inside onFinished() slot

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Highlighted
New Developer
Posts: 41
Registered: ‎08-02-2014
My Device: BlackBerry Z10
My Carrier: Wind Mobile

Re: requestFocus() doesn't stick

[ Edited ]

Thanks ekke for your reply. The error message is shown through a Label.

Anyways, I put this in the Textfield:
focusRetentionPolicyFlags: FocusRetentionPolicy.LoseOnScroll

I don't have scrollable content, so I think the keyboard will always pop up. Take a look at the Password Keeper app. When it asks for your password, the virtual keyboard always shows up, regardless of where you tap. I noticed that the password prompt on the device acts like my app though.

 

Any better ways to do this?