系统对话框的背景不模糊/熏黑莓

时间:2013-07-30 07:34:07

标签: qml blackberry-10 blackberry-cascades

我在这里创建了一个dialog.qml代码:

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();
                    }
                }
            }
        }
    }
}

我在这里打电话给对话

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

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

这里的问题是当对话框弹出时,屏幕没有变黑或模糊不像我们真正期望的那样弹出系统对话框,并且背景像iOS中的叠加层一样模糊

这是从当前版本中发生的事情:

enter image description here

1 个答案:

答案 0 :(得分:1)

由于您使用的是自定义对话框,因此您需要自己完成。因此,如果您要禁用并禁用基础页面的所有触摸事件,请将其置于打开自定义对话框的位置(即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();
}

与此类似,您必须在关闭对话框时恢复控件(在onBack()处理程序中 - 请参阅下面对话框的修改代码):

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

以下是修改后的代码对话框,当您按“x”按钮时发出信号back()(如果您的代码正确):

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();
                    }
                }
            }
        }
    }
}