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
Posts: 571
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use
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!

Developer
Posts: 150
Registered: ‎02-01-2009
My Device: Torch, PlayBook and Dev Alpha

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

 

Developer
Posts: 1,636
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, 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
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 571
Registered: ‎10-17-2010
My Device: (BlackBerry Z10)-> Q10/Passport Dual Use

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: