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
Regular Contributor
JohnQtQml
Posts: 55
Registered: ‎10-31-2012
My Device: Blackberry 10 Dev Alpha Simulator - VMware

How do you attach a button to a SystemToast?

Hi, I am using a SystemToast for displaying messages, but I need to add a button so the user can control when it disappears.  The documentation says that you can add a button to a SystemToast, but it doesn't show how to do it, and I can't find anything on that.  I just need some small sample code.

 

Right now I have:

 

Container {

   attachedObjects: [

       SystemToast {

            objectName: "msgBox"

        }

    }

}

 

inside my qml, and then I just refer to it in my C++, and use the setBody and show functions.

Please use plain text.
Regular Contributor
Q-T
Posts: 94
Registered: ‎12-02-2011
My Device: non-Blackberry user

Re: How do you attach a button to a SystemToast?

I think you just get the handle to to the button from Toast and explicitly set its text and maybe to a enable or show

Please use plain text.
Regular Contributor
JohnQtQml
Posts: 55
Registered: ‎10-31-2012
My Device: Blackberry 10 Dev Alpha Simulator - VMware

Re: How do you attach a button to a SystemToast?

Thankyou. I'm already doing that.  But it only shows for 3 seconds, which is really short for the length of my messages.  I need to add an OK button that a user can click when they are done reading the toast.  All of the other similar controls in Blackberry Cascades have extra buttons, and textfields, etc, but I only need one button, not those extras buttons or textfields.

Please use plain text.
Regular Contributor
Q-T
Posts: 94
Registered: ‎12-02-2011
My Device: non-Blackberry user

Re: How do you attach a button to a SystemToast?

yeh there has been a lot of gripes about the time of Toast, hope they get it to where it can be set by an API. for right now I think you are SOL.  If you need your own controls your going to have to create your own dialog

Please use plain text.
Developer
tanphat1412
Posts: 125
Registered: ‎11-06-2012
My Device: BlackBerry

Re: How do you attach a button to a SystemToast?

I haven't done that before, but you can see this post for more detail

http://supportforums.blackberry.com/t5/Cascades-Development/Beta-4-Toast-with-button-bug/td-p/201122...

Please use plain text.
Regular Contributor
JohnQtQml
Posts: 55
Registered: ‎10-31-2012
My Device: Blackberry 10 Dev Alpha Simulator - VMware

Re: How do you attach a button to a SystemToast?

I got it working, using a SystemDialog, with:

 

Container {

 

    id: errorView

    objectName: "errorView"

 

    attachObjects: [

        SystemDialog {

            id: msgBox

            objectName: "msgBox"

            cancelButton.label: undefined

        }

    ]

}

Please use plain text.
Contributor
maxxmus
Posts: 10
Registered: ‎03-03-2013
My Device: 8800

Re: How do you attach a button to a SystemToast?

I creat Toast from c++:

SystemProgressToast *progresstoast = new SystemProgressToast(this);

progresstoast->setBody("Photo upload");
progresstoast->setProgress(0);
progresstoast->setStatusMessage("Uploading ...");
progresstoast->setState(SystemUiProgressState::Active);
progresstoast->setPosition(SystemUiPosition::MiddleCenter);
progresstoast->button()->setLabel("Cancel");
progresstoast->show();
Please use plain text.
Developer
matizeitune
Posts: 366
Registered: ‎07-15-2013
My Device: blackberry Z10

Re: How do you attach a button to a SystemToast?

import bb.cascades 1.0
import bb.system 1.0

MenuDefinition {
    
    

     
     
    helpAction: HelpActionItem {

        onTriggered: {
            toast.body = qsTr("text")
            toast.show();
        }
    }


    attachedObjects: [
        SystemToast {
            id: toast
            body: "Toasty"
        }
    ]
}

 

If you find this information useful please click like --->
@mezeitune on twitter
Please use plain text.