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
Ebscer
Posts: 875
Registered: ‎08-31-2009
My Device: 9530, 9630, 9800, 8530, 9900, 9810, 9930, PlayBook, Dev Alpha

Re: Beta 4 Toast with button bug

How do you tell if the button has been clicked, versus the toast just being dismissed automatically?


Read my thoughts on BlackBerry Development at news.ebscer.com
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: Beta 4 Toast with button bug

Youd get that from systemuiresult in the finished signal.

finished (bb::system::smileyfrustrated:ystemUiResult::Type value)

With enum values as such: None = = 0, ButtonSelection = = 1, ConfirmButtonSelection = = 2, CancelButtonSelection = = 3, TimeOut = = 4, Error = = 5, CustomButtonSelection = = 6
Like all of my posts
Developer
jaiaca
Posts: 96
Registered: ‎10-06-2012
My Device: Z10

Re: Beta 4 Toast with button bug

When testing this out I couldn't get enum to actually work, had to use the integer values...

 

//myQmlToast.result = 1 for button selected
//myQmlToast.result = 4 for toast timed out

//using 'ButtonSelection' - not working


if (myQmlToast.result == 1) { 
    helloLabel.text = qsTr("Hello Toast");
}

 

I've put together sample code - HelloToast similar to my HelloBBM which shows how to use the button and interaction with the user. Also included changing the toast message via C++ signal

 

Check it out and let me know if you have any questions or even suggestions on making the code better.

One thing I'd like to figure out is how to add the button to system toast via C++

 

http://twocasualcoders.com/2012/12/10/hello-toast-blackberry-10-beta-4

 

Thanks

Jason I. Carter
Follow me @jasonicarter
Built For BlackBerry - WordsPlus & WordsPlus: Free Edition | word search has never had it so good
www.twocasualcoders.com | never casual on quality
Developer
strobejb
Posts: 282
Registered: ‎10-15-2012
My Device: bb10 developer

Re: Beta 4 Toast with button bug

You need to provide the class that the enum lives within:

 

i.e.

 

SystemUiResult.CancelButtonSelection

 

Developer
jaiaca
Posts: 96
Registered: ‎10-06-2012
My Device: Z10

Re: Beta 4 Toast with button bug

[ Edited ]

Great! that was too easy. Thanks a lot. I've updated my sample code

Jason I. Carter
Follow me @jasonicarter
Built For BlackBerry - WordsPlus & WordsPlus: Free Edition | word search has never had it so good
www.twocasualcoders.com | never casual on quality
Developer
Royster86
Posts: 102
Registered: ‎03-13-2012
My Device: 9360, P'9981, Z10

Re: Beta 4 Toast with button bug

If anyone is still wondering about how to attach a button to a Toast using C++, you can use the following:

 

myToast->button()->setLabel("OK");