09-30-2012 10:01 AM - edited 09-30-2012 02:33 PM
Is there way to set focus to TextField control?
Solved! Go to Solution.
10-04-2012 08:22 AM
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?
10-05-2012 04:58 AM
No idea?
Can someone comfirm, that this is currently not possible?
Thanks.
10-05-2012 05:32 AM
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?
10-05-2012 06:28 AM - edited 10-05-2012 06:30 AM
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...
10-22-2012 11:27 AM - edited 10-22-2012 12:09 PM
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!
10-23-2012 11:00 AM
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)
03-13-2013 07:50 AM