1

I want to show a splash page when the user clicks on the application icon. For this I've created Sheet and attached to the page. main.qml

import bb.cascades 1.0

Page {
    Container {
        Label {
            text: "Home page"
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
        }
    }
    attachedObjects: [
        Sheet {
            id: mySheet
            content: Page {
                Label {
                    text: "Splash Page / Sheet."
                }
            }
        }
    ]//end of attached objects
    onCreationCompleted: {

        //open the sheet
        mySheet.open();

        //After that doing some task here.
       ---------
       ---------
       ---------

       //Now I'm closing the Sheet. But the Sheet was not closed.
       //It is showing the Sheet/Splash Page only, not the Home Page
       mySheet.close();
    }
}//end of page

After completion of the work, I want to close the Sheet. So I've called the close () method.But the Sheet was not closed.

How do I close the sheet in oncreationCompleted() method or from any c++ method?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
user2636874
  • 889
  • 4
  • 15
  • 36
  • Did you try to put a log before/after ``mySheet.close();``, just to be sure you reach it? – Marc Plano-Lesay Aug 06 '13 at 12:20
  • yes, i've tested that and it is printing the log message also. – user2636874 Aug 06 '13 at 12:37
  • 1
    How much time is your task taking? Maybe the sheet is not yet completely opened (animation is maybe not ended) when you try to close it. – Marc Plano-Lesay Aug 06 '13 at 12:40
  • I'm new to cascades framework and c++. As of now i'm not doing any task after opening the sheet. Just opening the sheet and closing the sheet. Now i'm trying to close the sheet after opening it. I'm successfully opening the sheet but i'm unable to close the sheet. Could you please suggest me how to close the sheet either from qml or from c++ function. – user2636874 Aug 06 '13 at 12:51
  • I guess that's your issue, then. I think you'll have to wait for ``opened()`` (http://developer.blackberry.com/cascades/reference/bb__cascades__abstractdialog.html#function-opened) signal to be emitted before beeing able to close your ``Sheet``. – Marc Plano-Lesay Aug 06 '13 at 12:58
  • So how should i track whether the sheet is opened or not? – user2636874 Aug 06 '13 at 13:03
  • Hey i've successfully closed the sheet. I've overridden the onOpened() method. In that i've called the sheet.close() method. Thanks for your advice. – user2636874 Aug 06 '13 at 13:13
  • Right. Then you'll have to check here if your task is finished, and when your task is finished, check if the ``Sheet`` is opened, to cover both cases (task finishes before the ``Sheet`` is opened, or after). – Marc Plano-Lesay Aug 06 '13 at 13:14

1 Answers1

1

You are trying to close the Sheet before it's opening is complete (the animation is still running), so the close request is ignored by it. You have to monitor the end of the animation (opened() signal) to know if your Sheet is opened yet. I would do something like that:

import bb.cascades 1.0

Page {
    Container {
        Label {
            text: "Home page"
            verticalAlignment: VerticalAlignment.Center
            horizontalAlignment: HorizontalAlignment.Center
        }
    }
    attachedObjects: [
        Sheet {
            id: mySheet
            property finished bool: false
            content: Page {
                Label {
                    text: "Splash Page / Sheet."
                }
            }
            // We request a close if the task is finished once the opening is complete
            onOpened: {
                if (finished) {
                    close();
                }
            }
        }
    ]//end of attached objects
    onCreationCompleted: {

        //open the sheet
        mySheet.open();

        //After that doing some task here.
       ---------
       ---------
       ---------

       //Now I'm closing the Sheet. But the Sheet was not closed.
       //It is showing the Sheet/Splash Page only, not the Home Page
       mySheet.finished = true;
       // If the Sheet is opened, we close it
       if (mySheet.opened) {
           mySheet.close();
       }
    }
}//end of page
Marc Plano-Lesay
  • 6,808
  • 10
  • 44
  • 75
  • Take care, for some OS this signal is not sent. I had to use a QTimer and check "isOpened()" status to close it manually – Benoit Aug 06 '13 at 13:36
  • Instead of closing the sheet directly in onOpened() method, I tried as you mentioned in the code. Then the sheet is not closing. – user2636874 Aug 07 '13 at 06:53
  • Add console.log("onOpened"); to be sure that this slot is called – Benoit Aug 07 '13 at 16:16