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
calicratis19
Posts: 163
Registered: ‎12-06-2012
My Device: Z10, Q10
Accepted Solution

Creating a page by clicking on an application menu and then back

Hi I am wondering how do I create a page from application menu so that after clicking and viewing the page I can get back to the tab of the tabbed pane I originally was. I know there is a triggered() signal. And with slot method I create a page everytime a menu item is clicked. And if I set the page as app's scene than I can't go back. How do I do it? Thanks.

Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Creating a page by clicking on an application menu and then back

[ Edited ]

Hi! Replacing the scene is not convenient in most situations.
Other options are:
- Present the page in a sheet. Drawback: can't close the page by dragging it to the right, but the peek works and it can be closed by clicking a Back button.
- Add NavigationPanes as top-level items of every Tab. Push the page to NavigationPane of active tab. Temporarily disable the application menu until the page is popped.

I usually implement options menu using the second scenario. Can post my C++ code if it will help.


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
calicratis19
Posts: 163
Registered: ‎12-06-2012
My Device: Z10, Q10

Re: Creating a page by clicking on an application menu and then back

Thanks for reply. I can do it on my own.But if anyone else also stumbles on this problem your code might help them too. So please post them :smileyhappy: Thanks.
Please use plain text.
Developer
Zmey
Posts: 1,512
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Creating a page by clicking on an application menu and then back

I've just remembered that I've arleady posted it. :smileyhappy:

http://supportforums.blackberry.com/t5/Cascades-Development/How-would-you-implement-Application-Menu...


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
calicratis19
Posts: 163
Registered: ‎12-06-2012
My Device: Z10, Q10

Re: Creating a page by clicking on an application menu and then back

[ Edited ]

Ok it works. I am posting detailed code so others can find it useful.

Creating tabbed pane and two tab and create a navigation page for each of the tab. push the pages for each tab on to the navigation pane.

 

Flash::Flash(bb::cascades::Application *app):QObject(app)
{
    this->app = app;

    tabbedPane = new TabbedPane;
    tabbedPane->setShowTabsOnActionBar(true);
    durationFlashText= durationStrobeText = frequencyText = NULL;

    flashLightTab = Tab::create().title(QString("Flash Light"));
    tabbedPane->add(flashLightTab);

    strobeTab = Tab::create().title(QString("Stroboscope"));
    tabbedPane->add(strobeTab);
    tabbedPane->setActiveTab(flashLightTab);
    navStrobe = new NavigationPane;
    navFlash = new NavigationPane;
    navStrobe->push(createStrobePage());
    navFlash->push(createFlashPage());
    strobeTab->setContent(navStrobe);
    flashLightTab->setContent(navFlash);

    helpItem = HelpActionItem::create().title(QString("Help"));
    shareItem = ActionItem::create().title(QString("Share"));
    connect(helpItem,SIGNAL(triggered()),this,SLOT(onHelpTriggered()));
    connect(shareItem,SIGNAL(triggered()),this,SLOT(onShareTriggered()));
    menu = Menu::create().help(helpItem).addAction(shareItem);
    connect(navStrobe, SIGNAL(popTransitionEnded(bb::cascades::Page*)), this,SLOT(onPopTransitionEnded(bb::cascades::Page* )));
    connect(navFlash, SIGNAL(popTransitionEnded(bb::cascades::Page*)), this,SLOT(onPopTransitionEnded(bb::cascades::Page* )));



    app->setScene(tabbedPane);
    app->setMenu(menu);
}

 push a page when help/share menu is clicked. you can clean the memory of that page after user pressed backbutton and poptransitionended signal is emitted. I didn't do it here to make it simple.

void Flash::onPopTransitionEnded(bb::cascades::Page* page)
{
	app->setMenuEnabled(true);
}

// SET HERE WHAT YOU WANTO DO WHEN HELP IS CLICKED FROM MENU
void Flash::onHelpTriggered()
{
       //disable the menu
	app->setMenuEnabled(false);
	if(tabbedPane->activeTab()==strobeTab)
		navStrobe->push(Page::create());

	else
			navFlash->push(Page::create());
}
// SET HERE WHAT YOU WANTO DO WHEN SHARE IS CLICKED FROM MENU
void Flash::onShareTriggered()
{


}

 

Please use plain text.