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 Contributor
mbrauh
Posts: 9
Registered: ‎04-16-2013
My Device: BB 10 Developer
My Carrier: --
Accepted Solution

attachedObject inside a signal?

[ Edited ]

Hello!

 

Is it possible to check(/call?) a signal inside of the attachedObject brackets, for example inside of a checkbox component?

 

CheckBox {

 

attachedObjects: [

   SystemToast {

      onCheckedChanged: {...}

   }

]

 

}

 

Thanks!

 

 

***Partial ANSWER & EDIT***

Don't nest them like that. Just call toastID.show() in the signal you wanted it associated with.

 

Still wondering best way/how to put logic inside of a system toast. For example, to make it say one thing if the box is checked, another if it is unchecked.

Please use plain text.
Developer
raj_jyani
Posts: 107
Registered: ‎05-11-2011
My Device: BlackBerry Z10 LE
My Carrier: AirTel

Re: attachedObject inside a signal?

Hi,

 

yes of course, you can take take advantage of SIGNAL and SLOT mechanism.

onCheckedChanged: {...} is a predefined handler for checkedChanged signal.

you can connect checkedChanged to your own function.

here code for you, try this

 

import bb.cascades 1.0
import bb.system 1.0

Page {
    Container {
        CheckBox {
            id: checkBox
            text: "check me"

            onCreationCompleted: {
                checkedChanged.connect(myToast.onCheckHandler);
            }

            attachedObjects: [
                SystemToast {
                    id: myToast
                    body: "So long! Thanks for coming, see you next time!"

                    function onCheckHandler(checked) {
                        body = "Item checked : " + checked;
                        show();
                    }
                }
            ]
        }
    }
}

 

Please use plain text.