0

I created a dialog.qml here's the code:

Dialog {
    id: dialog

    signal sampleSignal(string text);

    attachedObjects: [
        TextStyleDefinition {
            id: titleStyle
            base: SystemDefaults.TextStyles.BigText
            color: Color.create("#60323C")
        },
        TextStyleDefinition {
            id: titleTextStyle
            base: SystemDefaults.TextStyles.TitleText
            color: Color.Black
        }
    ]

    Container {
        id: mainContainer
        preferredWidth: 700 
        layout: DockLayout {}
        verticalAlignment: VerticalAlignment.Center;
        horizontalAlignment: HorizontalAlignment.Center;

        background: Color.create("#f9f7f2")

        Container {
            layout: StackLayout {}
            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Center

            Container {
                layout: DockLayout {}
                background: Color.create("#F4E9E1");
                horizontalAlignment: HorizontalAlignment.Fill;
                preferredHeight: 120
                rightPadding: 10
                leftPadding: 10

                Label {
                    text: "Members" ;              
                    verticalAlignment: VerticalAlignment.Center;
                    textStyle{
                        base: titleStyle.style
                    }
                }

                ImageView {            
                    verticalAlignment: VerticalAlignment.Center;
                    horizontalAlignment: HorizontalAlignment.Right;
                    imageSource: "asset:///images/close_button.png"
                    onTouch: {
                        dialog.close();
                    }
                }   
            }
            Container {
                layout: StackLayout {}
                topPadding: 20
                bottomPadding: 20
                rightPadding: 10
                leftPadding: 10

                TextField {
                    id: name
                    hintText: "Add email address"     
                    input {
                        submitKey: SubmitKey.Submit;
                        onSubmitted: {
                            cppObj.onEmailDoneClicked(name.text, "");
                        }
                    }         
                }

                Divider {}             

                ImageButton {
                    id: doneButton
                    defaultImageSource: "asset:///images/button_done.png"
                    horizontalAlignment: HorizontalAlignment.Center;
                    onClicked: {
                        cppObj.onEmailDoneClicked(name.text, "");
                        doneButton.textAdded();
                    }

                    function textAdded() {
                        dialog.sampleSignal(name.text);
                        dialog.close();
                    }
                }
            }
        }
    }
}

and I call that dialog here

ImageButton {
    id: btnaddmore
    defaultImageSource: "asset:///images/button_add.png"

    onClicked: {
    //controller.showProjectsPage();
    openDialog();
}

The problem here is when the dialog pops up, the screen is not blackened or blurred unlike what we really expect from system dialog like it pops up, and the background is blurred like an overlay in iOS

This is what happens from the current build:

enter image description here

Sunseeker
  • 1,503
  • 9
  • 21
kev
  • 155
  • 1
  • 11
  • Use a system dialog box instead. http://developer.blackberry.com/cascades/documentation/ui/dialogs_toasts/ – Konrad Lindenbach Jul 30 '13 at 19:57
  • 1
    There's no possibility to implement UI look&feel of the custom dialog provided using a `SystemDialog` class. The only possible way for doing this is to use `SystemPrompt` however it's still quite limited and couldn't be customised further. – Sunseeker Jul 31 '13 at 03:25

1 Answers1

1

Since you're using a custom dialog you need to do it by yourself. So, if you want to black out and disable all touch events of an underlying page, put this where you open your custom dialog (ie ImageButton):

ImageButton {
    id: btnaddmore
    defaultImageSource: "asset:///images/button_add.png"

    onClicked: {
    //controller.showProjectsPage();

    // --- black out and disable
    underlyingContainer.touchPropagationMode = TouchPropagationMode.None;
    underlyingContainer.opacity = 0.3;
    // --- black out and disable

    openDialog();
}

Similar to that, you'd have to restore controls back when you close the dialog (in onBack() handler - see modified code of your dialog below):

underlyingContainer.touchPropagationMode = TouchPropagationMode.Full;
underlyingContainer.opacity = 1.0;

Here is modified code for you dialog with signal back() being emitted when you press "x" button (if got your code right):

Dialog {
    id: dialog

    signal back();
    signal sampleSignal(string text);

    attachedObjects: [
        TextStyleDefinition {
            id: titleStyle
            base: SystemDefaults.TextStyles.BigText
            color: Color.create("#60323C")
        },
        TextStyleDefinition {
            id: titleTextStyle
            base: SystemDefaults.TextStyles.TitleText
            color: Color.Black
        }
    ]

    Container {
        id: mainContainer
        preferredWidth: 700 
        layout: DockLayout {}
        verticalAlignment: VerticalAlignment.Center;
        horizontalAlignment: HorizontalAlignment.Center;

        background: Color.create("#f9f7f2")

        Container {
            layout: StackLayout {}
            horizontalAlignment: HorizontalAlignment.Center
            verticalAlignment: VerticalAlignment.Center

            Container {
                layout: DockLayout {}
                background: Color.create("#F4E9E1");
                horizontalAlignment: HorizontalAlignment.Fill;
                preferredHeight: 120
                rightPadding: 10
                leftPadding: 10

                Label {
                    text: "Members" ;              
                    verticalAlignment: VerticalAlignment.Center;
                    textStyle{
                        base: titleStyle.style
                    }
                }

                ImageView {            
                    verticalAlignment: VerticalAlignment.Center;
                    horizontalAlignment: HorizontalAlignment.Right;
                    imageSource: "asset:///images/close_button.png"
                    onTouch: {
                        back();
                        dialog.close();
                    }
                }   
            }
            Container {
                layout: StackLayout {}
                topPadding: 20
                bottomPadding: 20
                rightPadding: 10
                leftPadding: 10

                TextField {
                    id: name
                    hintText: "Add email address"     
                    input {
                        submitKey: SubmitKey.Submit;
                        onSubmitted: {
                            cppObj.onEmailDoneClicked(name.text, "");
                        }
                    }         
                }

                Divider {}             

                ImageButton {
                    id: doneButton
                    defaultImageSource: "asset:///images/button_done.png"
                    horizontalAlignment: HorizontalAlignment.Center;
                    onClicked: {
                        cppObj.onEmailDoneClicked(name.text, "");
                        doneButton.textAdded();
                    }

                    function textAdded() {
                        dialog.sampleSignal(name.text);
                        dialog.close();
                    }
                }
            }
        }
    }
}
Sunseeker
  • 1,503
  • 9
  • 21
  • As I wrote before, you need to include code for restoring page to previous state in some handler called when you closing the dialog (read - emitting some signal). Since your dialog is a custom one, there's no such handler and you need to implement that on your own. I've done that for you in modified answer, so I hope it's clear how to deal with it if you're familiar with signal/slot paradigm in QML – Sunseeker Aug 01 '13 at 08:03