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
edusal100
Posts: 108
Registered: ‎09-21-2013
My Device: Blackberry Z10 STL100-1
My Carrier: Movistar
Accepted Solution

problems with request focus for a textfield

this is the page, what am i doing wrong?

 

import bb.cascades 1.0

Page {
    id:addPage
    property variant appScene: Application.scene
    
    // Custom signal for notifying that this page needs to be closed
    signal done ()
    
    titleBar: TitleBar {
        title: qsTr("Add Location") + Retranslate.onLocaleOrLanguageChanged
        dismissAction: ActionItem {
            title: "Cancel"
            onTriggered: {
                // Emit the custom signal here to indicate that this page needs to be closed
                // The signal would be handled by the page which invoked it
                addPage.done();
            }
        }
    }
    
    Container {
        background: Color.Transparent
        TextField {
            id: cityfield
            hintText: qsTr("Enter City or Postal Code") + Retranslate.onLocaleOrLanguageChanged
            inputMode: TextFieldInputMode.Text
            input.submitKey: SubmitKey.Search
            

        }

    }
    onAppSceneChanged: {
        // This triggers focus if the application scene is set to
        // this QML Page.
        cityfield.requestFocus();
}
}

Please use plain text.
BlackBerry Development Advisor (Retired)
erahnenfuehrer
Posts: 85
Registered: ‎05-25-2012
My Device: Limited Edition Z10
My Carrier: Bell

Re: problems with request focus for a textfield

Do you want the text field to get focus (and pull up the virtual keyboard on Z-devices) as soon as the page is loaded?

 

Try creating a property on the qml page:

 

property bool showVKB: false

 And add this method in your qml:

 

 onShowVKBChanged: {
        if (showVKB) {
            // This focus request shows the VKB if the Page is created via a ComponentDefinition (see main.qml)
            tfWord.requestFocus();
        }
    }

 And then in your qml page that pushes this page, set the showVKB property:

 

navigationPane.push(page);
page.showVKB = true;

 

 

 

Please use plain text.
Developer
edusal100
Posts: 108
Registered: ‎09-21-2013
My Device: Blackberry Z10 STL100-1
My Carrier: Movistar

Re: problems with request focus for a textfield

Hi and tnks for your reply, seems a good solution, but I got a problem with the last part, I don't know if is cause it's not a navigation pane but a sheet what I'm working with

I have it as an attached object and then I open it on an action item

attached objects: [
Sheet {
id: addSheet
peekEnabled: false

AddPage{
id: addPage

onDone: {
addSheet.close();
}
}
}
]
Please use plain text.
Developer
edusal100
Posts: 108
Registered: ‎09-21-2013
My Device: Blackberry Z10 STL100-1
My Carrier: Movistar

Re: problems with request focus for a textfield

Tnks man, I finally make it work :smileyhappy:
Please use plain text.
Developer
elemtype
Posts: 15
Registered: ‎02-20-2014
My Device: Z10
My Carrier: china mobile

Re: problems with request focus for a textfield

cool,that's i want....

Please use plain text.