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
New Developer
Ooata
Posts: 10
Registered: ‎01-14-2013
My Device: Blackberry 10 Simulator
My Carrier: EE
Accepted Solution

Possible to click on URL in label?

Hi

 

I am making an app that can show comments that people have submitted - I'd like to be able to allow the the user to click on a link in the comments and either open the browser or a webview to that link. 

 

Is this possible? I've tried searching but I'm not sure on the wording of my request.

Please use plain text.
Contributor
selvaraman
Posts: 29
Registered: ‎09-07-2012
My Device: 9900
My Carrier: Airtel

Re: Possible to click on URL in label?

Implement the onTouch event for Label and pass the url to webview in event.isUp() method

onTouch: {
if (event.isUp()) {

webview_id.url = url

webvbiew.visible = true
}
if (event.isDown() || event.isMove()) {
//display focus
} else {
//undisplay focus
}
}

 

Find the more information about webview here

https://developer.blackberry.com/cascades/reference/bb__cascades__webview.html

Please use plain text.
Developer
BBSJdev
Posts: 5,948
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: Possible to click on URL in label?

I haven't tried it but if you are using a control that can use a TextStyleDefintion then you can format the text as HTML and since it has the <a> attribute I would surmise it would open a browser, info here...

 

https://developer.blackberry.com/cascades/documentation/ui/text/styles.html

 

 


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.
Please use plain text.
Developer
bcs925
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30
My Carrier: T-Mobile

Re: Possible to click on URL in label?

If you use a TextArea (and if you want it to look like a Label, turn editable to false) hyperlinks will be "clickable" and open in the native browser.

---
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.
Developer
thubalek
Posts: 318
Registered: ‎10-01-2012
My Device: Dev Alpha C, Playbook 32 GB
My Carrier: BleskMobil

Re: Possible to click on URL in label?

Most easy way is following:

 

Label {
text: qsTr("Plese don't hesitate to provide feedback at http://blackberry.hubalek.net")
multiline: true
content.flags: TextContentFlag.ActiveText
}

 

content.flags: TextContentFlag.ActiveText does the trick.

 

If you like my solution please accept my response

--------------------------------------------------------------------------------------------
-- My Blackberry 10 app at http://blackberry.hubalek.net
-- My Android apps at http://android.hubalek.net
Please use plain text.