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
laurentC
Posts: 268
Registered: ‎02-05-2010
My Device: Blackberry Z10

SystemDialog

Hello,

I'm trying to implement a basic yes/no confirmation dialog.
I would use SystemDialog https://developer.blackberry.com/cascades/reference/bb__system__systemdialog.html but I need an example.
Can you help ?

Thanks,
Laurent

Twitter : @LaurentKP
My apps
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: SystemDialog

If invoking from C++:

 

  1. Add to the project file (.pro):
    LIBS += -lbbsystem


  2. Near top of C++ cpp file:
    #include <bb/system/SystemDialog>

  3. To bring up a dialog:
    bb::system::smileyfrustrated:ystemDialog* menu = new bb::system::smileyfrustrated:ystemDialog("ok", "cancel");
    menu->setTitle("My title");
    menu->setBody("This is the body");
    menu->show();

  4. Hook up the accepted and rejected signals
    I am not fluent in the meaning of "dismissAutomatically".  So for now I'd say be sure to call deleteLater here.

Stuart

Developer
laurentC
Posts: 268
Registered: ‎02-05-2010
My Device: Blackberry Z10

Re: SystemDialog

Oops sorry I would like a qml example...

Twitter : @LaurentKP
My apps
BlackBerry Development Advisor (Retired)
amarcon
Posts: 155
Registered: ‎07-16-2012
My Device: Dev Alpha

Re: SystemDialog

Perhaps, you could use CustomDialog.

 

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

 

Under the QML side, you will need to make it visible somehow, such as:

 

                Button {
	            text: "Pop"
	            layoutProperties: StackLayoutProperties {
	                horizontalAlignment: HorizontalAlignment.Center
	            }
	            onClicked: {
	                myCustomDialog.visible = true
	            }
	        }

 and then handle the events, such as:

 

attachedObjects: [
	CustomDialog {
	   id: myCustomDialog
	   content: Container {
	      Button {
	          text: "Yes"
	          onClicked: myCustomDialog.visible = false
	      }
	      Button {
   	          text: "No"
   	          onClicked: myCustomDialog.visible = false
   	       }
	   }
	}
]

 

Hope this helps.

 

Developer
laurentC
Posts: 268
Registered: ‎02-05-2010
My Device: Blackberry Z10

Re: SystemDialog

Yes this helps. I'll give it a try.
Thank you.
Twitter : @LaurentKP
My apps
BlackBerry Development Advisor (Retired)
amarcon
Posts: 155
Registered: ‎07-16-2012
My Device: Dev Alpha

Re: SystemDialog

That's great, let me know the results.

 

Cheers,

Developer
jamiejulius
Posts: 49
Registered: ‎06-06-2012
My Device: Bold 9700

Re: SystemDialog

Following 

 

 

 

SystemDialogEx::SystemDialogEx(QObject* parent)
: SystemDialog(parent)
{
}

SystemDialogEx::SystemDialogEx(const QString& confirmLabel, QObject* parent)
: SystemDialog(confirmLabel, parent)
{
}

SystemDialogEx::SystemDialogEx(const QString& confirmLabel, const QString& cancelLabel, QObject* parent)
: SystemDialog(confirmLabel, cancelLabel, parent)
{
}

SystemDialogEx::~SystemDialogEx()
{
}

void SystemDialogEx::showEx()
{
	QObject::connect(this, SIGNAL(accepted()), this, SLOT(onDismissed()));
	QObject::connect(this, SIGNAL(rejected()), this, SLOT(onDismissed()));
	QObject::connect(this, SIGNAL(error(bb::system::SystemUiErrors::Type)), this, SLOT(onError(bb::system::SystemUiErrors::Type)));

	show();
}

void SystemDialogEx::onDismissed()
{
	deleteLater();
}

void SystemDialogEx::onError(bb::system::SystemUiErrors::Type err)
{
	deleteLater();
}

 

Jamie

Developer
MFSI
Posts: 80
Registered: ‎09-03-2012
My Device: 9810

Re: SystemDialog

Hi smacmartin,

 

I am also trying to display a dialog, followed steps you wrote for dialog creation.

 

in my App() constructor , I have written the following code.

 

Container *mContainer = root->findChild<Container*>("myContainer");
    bb::system::SystemDialog *mSysDialog = new bb::system::SystemDialog("ok",
            "cancel", mContainer);
    mSysDialog->setTitle("Dialog");
    mSysDialog->setBody("hello hello hello hello");
    mSysDialog->show();

 

but on application execution dialog doesnot appear.

 

For simply creating a and displaying a dialog what else is required ?

 

Same  problem occurs when I am using SystemToast class.

 


 

 

Always Success
BlackBerry Development Advisor (Retired)
amarcon
Posts: 155
Registered: ‎07-16-2012
My Device: Dev Alpha

Re: SystemDialog

Hi MFSI,

 

I've made some quick tests here, you can try something like the samples below, m_mainPage comes from:

 

// The application Page is created from QML.
m_mainPage = qml->createRootNode<Page>();

 

app.cpp

mSysDialog = new bb::system::SystemDialog("ok","cancel", m_mainPage);
mSysDialog->setTitle("Dialog");
mSysDialog->setBody("hello hello hello hello");

mSysToast = new bb::system::SystemToast(m_mainPage);

still on app.cpp

 

void App::onButton1Clicked(){
    mSysDialog->show();
}

void App::onButton2Clicked(){
    mSysToast->show();
}

 app.hpp

bb::system::SystemDialog* mSysDialog;
bb::system::SystemToast* mSysToast;

Hope this helps.

 

 Cheers,

 

Developer
MFSI
Posts: 80
Registered: ‎09-03-2012
My Device: 9810

Re: SystemDialog

Thanks amarcon, for your reply.

 

But I want to clear one issue.

 

Is it necessary to connect dialog or toast with some other control and on emission of any signal from that control will invoke a slot that contains dialog's or toast's show() method ?

 

Can't we invoke show()  method just after its(dialog's or toast's) initialization the way I did in my previous.

 

Also it wont affect whether a Page or a Container object acts as parent for dialog and toast . It will work for both.

 

Actually problem in my case was that  I wasn't connecting Dialog or Toast with any other control.

 

 

Always Success