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: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers
Accepted Solution

Invoking browser by clicking on a button (QML)

Hello,

 

I'm trying to invoke the browser to a certain URL by clicking on a button. I have done InvokeActionItems where you just put in a query block and add the invokeTargetid, invokeActionId and uri. 

 

However for a button it seems a bit of an uneccessary hack and some messy code. This following code WORKS, but gives me an error at the "InvokeQuery" saying "Read only property cannot be set".

 

Here's the code. Does it all look right and can anything be cleaned up? The whole "onArmed" and Invocation attached object seems a bit weird.

 

Button {
                    id: googleMapButton
                    overlapTouchPolicy: OverlapTouchPolicy.Allow
                    text: "Google"
                    onClicked: {
                        invokeGoogleMapQuery.uri = "http://maps.google.com/"
                        invokeGoogleMapQuery.updateQuery();
                    }
                    
                    attachedObjects: [
                        Invocation {
                            id: invokeGoogleMap
                            query: InvokeQuery { // *error here
                                id: invokeGoogleMapQuery
                                invokeTargetId: "sys.browser"
                            }
                            onArmed: {
                                trigger("bb.action.OPEN")
                            }
                        }
                    ]

                }

 

Developer
Posts: 275
Registered: ‎02-05-2010
My Device: Blackberry Z10
My Carrier: Bouygues Telecom

Re: Invoking browser by clicking on a button (QML)

Hello,

this code works for me :

 

Button {	
	text: "Zoom"
	imageSource: "asset:///images/zoomin.png"

	onClicked: {		
		linkInvocation.query.uri = webView.url;
	}
	attachedObjects: [
		Invocation {
			id: linkInvocation
			property bool auto_trigger: false
			query {
				uri: "http://www.google.com"

				onUriChanged: {
					linkInvocation.query.updateQuery();
				}
			}
			onArmed: {				
				if (auto_trigger) trigger("bb.action.OPEN");
				auto_trigger = true; 
			}
		}
	]

}

 

Twitter : @LaurentKP
My apps
Developer
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers

Re: Invoking browser by clicking on a button (QML)

@laurentC

 

Tried your way, and it won't work. Clicking on the button doesn't do anything. Any ideas?

 

Thanks.

 

Button {
                        id: googleMapButton
                        text: "View in Google Maps"
                        onClicked: {
                            invokeGoogleMap.query.uri = "http://maps.google.com"
                        }

                        attachedObjects: [
                            Invocation {
                                id: invokeGoogleMap
                                property bool auto_trigger: false
                                query {
                                	uri: "http://maps.google.com/"
                                    onUriChanged: {
                                        invokeGoogleMap.query.updateQuery();
                                    }
                                }
                                onArmed: {
                                    if (auto_trigger) trigger("bb.action.OPEN")
                                    auto_trigger =  true;
                                }
                            }
                        ]
                    }

 

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

Re: Invoking browser by clicking on a button (QML)

Try this...

 

            Button {
                text: "Invoke Browser"
                onClicked: { invokeBrowser.trigger("bb.action.OPEN") }

                attachedObjects: [
                    Invocation {
                        id: invokeBrowser
                        query.invokeActionId: "bb.action.OPEN"
                        query.invokeTargetId: "sys.browser"
                        query.uri: "http://www.stok.biz"
                    }
                ]
            }

 


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: 193
Registered: ‎12-29-2010
My Device: Bold 9900
My Carrier: Rogers

Re: Invoking browser by clicking on a button (QML)

@BBSJdev - Thanks. That worked!