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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Developer
greenback
Posts: 453
Registered: ‎10-17-2010
Accepted Solution

Capturing AbstractActionItem SIGNAL from swipe down menu

Hi,

 

So I need to do something when I press on the ActionItem in the swipe down context menu on BB10.

 

I created the swipe down menu

 

    Menu *menu = Menu::create();
    Image infoIcon = Image(QUrl("asset:///images/info"));
    menu->addAction(ActionItem::create().title("Info").image(infoIcon));
    menu->setObjectName("infoItem");


Looked at the docs. AbstractActionItem

https://developer.blackberry.com/cascades/reference/bb__cascades__abstractactionitem.html

The action item emits a triggered() Signal.

Then ran info a bunch of issue which didn't help.

  • Looked at QTDocs
  • Looked at Signals & Slots Section of BB Cascades Docs

in my App.hpp file I added

public:
   void debugText();

 I tried connecting the menu using the following code:

 

connect(menu->objectName(), SIGNAL(triggered()), this, SLOT(debugText()));

 

It doesn't work, and I spent 2 hours trying to figure out why not. 
How do you actually connect these things?


Thanks!


Do people really want their phone making decisions for them? Whatever happened to the human element? Stop this madness!

Please use plain text.
Developer
nicklas
Posts: 131
Registered: ‎02-01-2009
My Carrier: SFR

Re: Capturing AbstractActionItem SIGNAL from swipe down menu

Hi,

 

triggered signal is attach to ActionItem itself and not Menu object.

 

And don't forget Q_SLOT macro.

 

class xxx : virtual QObject {
  Q_OBJECT

public:
  Q_SLOT void debugText(void);
};


Menu *menu = Menu::create();
Image infoIcon = Image(QUrl("asset:///images/info"));

ActionItem *mItem = ActionItem::create().title("Info").image(infoIcon)

menu->addAction(mItem);
menu->setObjectName("infoItem");

connect(mItem, SIGNAL(triggered()), this, SLOT(debugText()));

 

Nicklas

 

Please use plain text.
Developer
ekke
Posts: 940
Registered: ‎04-08-2010
My Carrier: vodafone

Re: Capturing AbstractActionItem SIGNAL from swipe down menu

[ Edited ]

take a look at my Open Source project

https://github.com/blackberry/opendataspace-cascades

 

Inside ...app.cpp you'll find the code to create an ApplicationMenu with some Actions and Howto connect the Actions with your code.

In my case I'm using Sheets to be displayed.

 

if you have any questions: I'm in San Jose next week

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
greenback
Posts: 453
Registered: ‎10-17-2010

Re: Capturing AbstractActionItem SIGNAL from swipe down menu

Ok. The code from nicklas worked. I was missin "Q_SLOT" type declaration in my header file.

 

Thank you nicklas, and ekke!
:Rockon:


Do people really want their phone making decisions for them? Whatever happened to the human element? Stop this madness!

Please use plain text.