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
nicklas
Posts: 150
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha

Issue to do a "swipe down" menu

Hi,

 

I have several issues to do a "swipe down" menu as the BlackBerry native web browser :

 

- no ListView horizontal scroll => OK I wait the next Cascades release.

 

- animation aren't smooth :smileysad:

 

            animations: [
                TranslateTransition {
                    id: "showMenuAnimation"
                    toY: 0
                    duration: 1000 
                    
                    onEnded: {
                    }
                },
                TranslateTransition {
                    id: "hideMenuAnimation"
                    toY: -347
                    duration: 1000

                    onEnded: {
                    }
                }
            ]

            function onSwipeDown() {
                if (isVisible)
                    hideMenuAnimation.play();
                else
                    showMenuAnimation.play();
                isVisible = !isVisible;
            }

 

Nicolas

 

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Issue to do a "swipe down" menu

Are you testing on a device or on the simulator?

You may find on the simulator that the user experience is not as slick as on the device.

 

Stuart

Please use plain text.
Developer
nicklas
Posts: 150
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha

Re: Issue to do a "swipe down" menu

Of course, I'm testing on a bb10 device.

In fact, the translation is smooth but doesn't respect always the duration. Sometimes the translation is very quick !

I have an other issue. I can't set the default position out of the screen. I want to set positonY to "-350" (with a negative value). It doesn't work. However, after a translation the value is negative...

Nicolas
Please use plain text.
Developer
blackqtcoder
Posts: 146
Registered: ‎05-18-2012
My Device: PlayBook & STL100-1 LE Z10 & Dev Alpha C

Re: Issue to do a "swipe down" menu

[ Edited ]
            animations: [
                TranslateTransition {
                    id: "showMenuAnimation"
                    fromY: -347        // NEW
toY: 0 duration: 1000 easingCurve: "CircularIn" // NEW
onEnded: { } }, TranslateTransition { id: "hideMenuAnimation" fromY: 0 // NEW
toY: -347 duration: 1000 easingCurve: "CircularIn" // NEW onEnded: { } } ]
---------------------------------------------------------------
Leandro Cerdan - Duantox Apps
BlackBerry Elite dev
TapyHold, Built for Blackberry multimedia scrapbook
Please use plain text.
Developer
nicklas
Posts: 150
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha

Re: Issue to do a "swipe down" menu

No difference. It's strange.

 

I test again later with new SDK and in release mode.

 

Nicolas

 

Please use plain text.
Retired
alarsson
Posts: 5
Registered: ‎04-10-2012
My Device: Curve

Re: Issue to do a "swipe down" menu

Hi Nicklas,

 

If you are trying to create an application menu, similar to this:  we have actually added dedicated functionality for it in Beta 2. Check out the documentation here , look for the setMenu function. This is only available in C++ currently but will eventually be available in QML as well.

 

Here is some simple code that adds a couple of items to a menu. I've modified the "Starship settings" example:

 

StarshipSettingsApp::StarshipSettingsApp()
{
 //... some starship settings code here that i left out

  // create a couple of actions
  ActionItem *pAI1 =  ActionItem::create().title("Menu Item 1");
  ActionItem *pAI2 =  ActionItem::create().title("Menu Item 2");
  HelpActionItem *pHelpAI = HelpActionItem::create();
  SettingsActionItem *pSettingsAI = SettingsActionItem::create();

  // connect them to signal handlers
  connect(pAI1, SIGNAL(triggered()), this, SLOT(generalTrigger()));
  connect(pAI2, SIGNAL(triggered()), this, SLOT(generalTrigger()));
  connect(pHelpAI, SIGNAL(triggered()), this, SLOT(helpTrigger()));
  connect(pSettingsAI, SIGNAL(triggered()), this, SLOT(settingsTrigger()));

  // create a menu and add it to the application instance
   Menu *menu = Menu::create();
   menu->addAction(pAI1);
   menu->addAction(pAI2);
   menu->setHelpAction(pHelpAI);
   menu->setSettingsAction(pSettingsAI);

   Application::instance()->setMenu(menu);
  //... some more code i left out
}

// my signal handlers

void StarshipSettingsApp::generalTrigger ()
{
	qDebug("General app menu item");
}

void StarshipSettingsApp::helpTrigger ()
{
	qDebug("Help me!!");
}

void StarshipSettingsApp::settingsTrigger ()
{
	qDebug("Settings!!");
}

 Hope this helps!

 

Cheers

Anders

Please use plain text.
Developer
vingilot
Posts: 224
Registered: ‎03-29-2012
My Device: 9900

Re: Issue to do a "swipe down" menu

Can this still be used if we primarily use QML? or should we just wait, I mean what additional steps would be needed to get it running if everything else is mostly QML

Please use plain text.
Retired
alarsson
Posts: 5
Registered: ‎04-10-2012
My Device: Curve

Re: Issue to do a "swipe down" menu

No, I think you can using it right away. The swipe down menu is supposed to be used for static, global and quite rarely used application features, so setting them up when you start your application (as in my example) is usually what you'd want to do anyway.
What you can do from the signal handlers is to keep them simple in C++ and just notify your QML.
You can for example declare a couple of signals in your application class, one for each item in your application menu and send them off to your app in qml using a context object. This outlines the strategy:

 

StarshipSettingsApp.h

class StarshipSettingsApp : public QObject
{
...
 Q_SIGNAL void helpSettingsPressed ();
...
}

 StarshipSettingsApp.cpp

StarshipSettingsApp::StarshipSettingsApp()
{
...
  QmlDocument *qml = QmlDocument::create().load("main.qml");
  // expose this object as a context property
  qml->setContextProperty("_starshipApp", this);
...
}
...
void StarshipSettingsApp::helpTrigger ()
{
        // emit a signal that can be received in qml
	emit helpSettingsPressed();
}

 main.qml

Page {

...
  // somewhere in your qml, connect the signals
    onCreationCompleted: {
       _starshipApp.helpSettingsPressed.connect(onHelpSettingsPressed);
    }
    
  // handle the signal when the help button is pressed
    function onHelpSettingsPressed () {
        console.log("Success!!");
    }
}

 When you get the C++-code working, you can more or less stop caring about it and implement all your logic in QML.

 

Please use plain text.
Developer
nicklas
Posts: 150
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha

Re: Issue to do a "swipe down" menu

[ Edited ]

My menu works well with beta 2 except that I can't bind the swipeDown event :smileysad:

 

The signal isn't emit.

 

I hope that RIM will fix it in the next release !

 

My swipeDown menu seems to PlayBook menu ; so :

 

IMG_00000001.png IMG_00000002.png

 

IMG_00000003.png

 

With and without menu :smileyhappy:

 

Nicolas

 

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Issue to do a "swipe down" menu

I reproduced your issue with the swipeDown signal.  In HelloCascades the following line:

    QObject::connect(&app, SIGNAL(swipeDown()), &mainApp, SLOT(swipeDownMenu()));

 

does not complain but I do not get the swipeDownMenu slot called.  I'll look further.

 

In the meantime, have a look at https://developer.blackberry.com/cascades/reference/bb__cascades__menu.html:

 

    Menu *menu = Menu::create()
        .addAction(ActionItem::create().title("Menu Item 1"))
        .addAction(ActionItem::create().title("Menu Item 2"))
        .help(HelpActionItem::create());
    Application::setMenu(menu);

 

Stuart

Please use plain text.