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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Contributor
nrjg
Posts: 37
Registered: ‎09-14-2012
My Carrier: -
Accepted Solution

TextField focus

[ Edited ]

Is there way to set focus to TextField control?

 

Please use plain text.
Trusted Contributor
georg22
Posts: 213
Registered: ‎11-22-2011
My Carrier: vodafone

Re: TextField focus

I have the same question.

 

How can i set the focus to a textfield control? 

 

For example in the calendar app: When i tap on "Search" the search page opens and the search-TextField has focus and the keyboard appears automatically. How is that done?

Please use plain text.
Trusted Contributor
georg22
Posts: 213
Registered: ‎11-22-2011
My Carrier: vodafone

Re: TextField focus

No idea?

Can someone comfirm, that this is currently not possible?

 

Thanks.

Please use plain text.
Developer
kanaksony
Posts: 528
Registered: ‎04-11-2009

Re: TextField focus

Hi,

 

I am having a Search functionality in my app. 

 

QML is - 

TextField {
	       objectName: "searchField"
	       id: searchField
	       clearButtonVisible: true
	       hintText: "Search for Directory"
		       onTextChanging: {
	                        console.log("------Search Bar Text Changing-----------");
	                        directory.searchDirectory();
                       }
}

 

CPP code looks like

void DirectoryList::searchDirectory()
{
	TextField *searchField = page->findChild<TextField*>("searchField");
	QString searchText = searchField->text().trimmed();
	if(searchText!=NULL && searchText.length()>0)
		loadData(searchText);
}

When I tap on TextField, it has Keyboard Up and it seeems focusable. Is it anything else you are asking for, If I am wrong?

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Please use plain text.
Trusted Contributor
georg22
Posts: 213
Registered: ‎11-22-2011
My Carrier: vodafone

Re: TextField focus

[ Edited ]

Thanks kanaksony.

No thats not what i am asking for. The Textfield gets automatically the focus by tapping on it or when you swipe the keyboard into the screen. Works fine so far. 

But when you look at the contacts app this happens simply by opening the search page.

The user does not need to tap on the textfield to raise the keyboard or swipe the keyboard into the screen.  

So there must be a way to set the focus on a specific textfield programmatically. 

It is easy iwith the AIR SDK and i allway used it...

Please use plain text.
Developer
d3v3l0p3r
Posts: 130
Registered: ‎07-19-2012
My Carrier: Carrier

Re: TextField focus

[ Edited ]

I'm searching for the same ---- want to be abe to open keyboard from JavaScript in QML and set focus to a different (specific) textbox without requiring user to tap on that textbox.

 

 

EDIT:  I found a solution for opening keyboard - although it is not entirely done in QML.

 

Simply created c++ class with Q_INVOKABLE method called showVirtualKeyboard().

 

Inside that method I am calling the

virtualkeyboard_show();

 function which requires the 

bps/virtualkeyboard.h

 header to be included.

 

Exposed this class to QML using 

 

qml->setContextProperty("keyboardControl", myClass);

 and then from QML function called:

keyboardControl.showVirtualKeyboard();

 works fine.

 

Now I can set the focus of specific textbox in QML by calling:

myTextField.requestFocus();

 Works great in beta 3!

---
If you find my post helpful please "like" it and "accept as a solution"
Please use plain text.
Contributor
nrjg
Posts: 37
Registered: ‎09-14-2012
My Carrier: -

Re: TextField focus

Thanks, it realy works!

 

Summarizing solution is:

1. Show Virtual Keyboard by virtualkeyboard_show (from bps/virtualkeyboard.h)

2. Request focus by requestFocus (defined in Control)

Please use plain text.
Developer
bcs925
Posts: 212
Registered: ‎07-13-2012
My Carrier: T-Mobile

Re: TextField focus

@d3v3l0p3r Do you have a simple example (or full cpp, hpp, and qml) sample code to show where all these pieces go? I need to do exactly this but I am getting lost somewhere with the different pieces. Thanks.
---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Please use plain text.