07-13-2012 01:27 PM
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 ![]()
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
07-17-2012 09:24 AM
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
07-17-2012 09:33 AM
07-18-2012 03:48 PM - edited 07-18-2012 03:53 PM
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: {
}
}
]
07-18-2012 05:13 PM
No difference. It's strange.
I test again later with new SDK and in release mode.
Nicolas
07-19-2012 03:58 PM
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
07-19-2012 04:11 PM
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
07-20-2012 04:41 AM
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(onHelpSet tingsPressed);
}
// 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.
08-16-2012 05:41 PM - edited 08-16-2012 05:43 PM
My menu works well with beta 2 except that I can't bind the swipeDown event ![]()
The signal isn't emit.
I hope that RIM will fix it in the next release !
My swipeDown menu seems to PlayBook menu ; so :
With and without menu ![]()
Nicolas
08-17-2012 11:11 AM
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/referenc
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