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: 188
Registered: ‎04-07-2013
My Device: BlackBerry Z10
My Carrier: Telus
Accepted Solution

SystemToast onTriggered?

Hi, how do I trigger something when user press a button on SystemToast?

 

I only know how to declare it.

 

Anythought please??

 

SystemToast *toast = new SystemToast(0);

toast->setBody("Success.");
toast->button()->setLabel("Ok");
toast->show();

jayvdiyk.com
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: SystemToast onTriggered?

[ Edited ]

Connect to it's finished() signal after creation, this thread has an example:

 

http://supportforums.blackberry.com/t5/Cascades-Development/finished-signal-for-a-system-toast/m-p/2...

 

Set SystemToast's parent to some other class on creation, for example new SystemToast(this).

This way it will be destroyed when the parent is destroyed.

 

You might also want to destroy it in onFinished() slot as well. This can be done like this:

void YourClass::onFinished(bb::system::SystemUiResult::Type uiResult)
{ ... process the result ...
SystemToast *toast = qobject_cast<SystemToast *>(sender()); toast->deleteLater(); }

Otherwise the instance will continue to exist and will be destroyed only when it's parent is destroyed. 

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 188
Registered: ‎04-07-2013
My Device: BlackBerry Z10
My Carrier: Telus

Re: SystemToast onTriggered?

void HelpPage::showToastNotification()
{
	SystemToast *toast = new SystemToast(this);
	toast->setBody("Success.");
	toast->button()->setLabel("Open");

	QObject::connect(toast, SIGNAL(finished(SystemUiResult::Type)),
	        this,  SLOT(onToastFinished(SystemUiResult::Type)));

	toast->show();
}

void HelpPage::onToastFinished(bb::system::SystemUiResult::Type result)
{
      showDialog("Test","Success"); //THIS LINE NEVER GETS CALLED

      SystemToast *toast = qobject_cast<SystemToast *>(sender());
      toast->deleteLater();
}

 

Yeah, but it seems like the onToastFinished never gets called.. ANy idea why? Thanks

jayvdiyk.com
Developer
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

Re: SystemToast onTriggered?

Hi,

 

for use SIGNAL - SLOT in your class you must use Q_OBJECT Macro and  defination of your method should be like

 

public slots:
    void onToastFinished(bb::system:Smiley FrustratedystemUiResult::Type);

Developer
Posts: 188
Registered: ‎04-07-2013
My Device: BlackBerry Z10
My Carrier: Telus

Re: SystemToast onTriggered?

Yes, I have that too, but it doesnt work
jayvdiyk.com
Developer
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel