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: 289
Registered: ‎07-20-2012
My Device: Blackberry Z10 (White), BlackBerry Dev Alpha C
My Carrier: O2 UK

Searching Headers & Labels

Hello, 


I am working on an app that has a page which consists of just headers and labels. I was wondering if it's possible to create a search form (like find on page in the browser) that will search the headers and labels? 

 

I already have a textField set up: 

 

Container {

            Container {
                id: searchContainer
                visible: false
                background: Color.create("#212121")
                layout: StackLayout {
                    orientation: LayoutOrientation.LeftToRight
                }
                leftPadding: 10.0
                rightPadding: 10.0
                topPadding: 15.0
                bottomPadding: 15.0
                TextField {
                    id: urlBar
                    layoutProperties: StackLayoutProperties {
                        spaceQuota: 3.0
                    }
                    hintText: "Search..."
                    verticalAlignment: VerticalAlignment.Center
                    textFormat: TextFormat.Plain
                    onFocusedChanged: {
                        if (focused == true) {

                        }
                    }
                    inputMode: TextFieldInputMode.Default
                    input.submitKey: SubmitKey.Search

                    onTextChanging: {
                    }
                }
                Button {
                    text: qsTr("Cancel")
                    layoutProperties: StackLayoutProperties {
                        spaceQuota: 1.0
                    }
                    onClicked: {
                        urlBar.text = ""
                        searchContainer.setVisible(false)
                    }
                }
            }

 Thanks in advance :smileyhappy:

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

Re: Searching Headers & Labels

I wrote a Scene Graph Scanner a while back, there's no reason you can't adapt that to search in the controls you want...

 

http://supportforums.blackberry.com/t5/Native-Development/Scene-Graph-scanner/m-p/2778799/highlight/...


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Searching Headers & Labels

Another way to do it would be to customise your headers and labels and add a search slot, tie that to your search term mechanism and when you emit the signal they fire back a found signal if there is a match.


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 289
Registered: ‎07-20-2012
My Device: Blackberry Z10 (White), BlackBerry Dev Alpha C
My Carrier: O2 UK

Re: Searching Headers & Labels

The second option seems more fitting to what I need it to do.

Could you explain a little further how I need to customize my headers, labels and then how to add a search slot please? :smileyhappy:
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Searching Headers & Labels

[ Edited ]

Just create a custom control...

 

SearchableLabel.qml

signal found()

function search(searchTerm) {
    if (searchTerm == l.text)
        emit found();
}

Label {
    id: l
}

  - Connect your Search button signal to each SearchableLabel search slot

  - Connect all the found signals to a function that displays the found Header / Label

     - Depending on what you are listing here you would need to pass back either the l.text or id/objectName of the control

 

Code might not be accurate as I don't have a working IDE at the mo but hopefully you get the jist.

 


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

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 289
Registered: ‎07-20-2012
My Device: Blackberry Z10 (White), BlackBerry Dev Alpha C
My Carrier: O2 UK

Re: Searching Headers & Labels

Yep, I understand what you mean; it's just working out how to implement it into my app. 

 

Do I need to create the custom control in C++ first to then call it from the QML?

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

Re: Searching Headers & Labels

No, c++ or QML is fine.

You might find it slightly easier to do all the signal connections, and do them dynamically, if you do it in C++.

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

Developer of stokLocker, Sympatico and Super Sentences.