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: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T
Accepted Solution

Add onTriggered to c++ created ActionSet

In the ActionSet documentation, it shows 2 ActionSets for an image

 

ImageView {
    imageSource: "john.png"
    contextActions: [
        ActionSet {
            title: "Email"
            subtitle: "From: John Doe"
            ActionItem {title: "Reply"}
            ActionItem {title: "Forward"}
        },
        ActionSet {
            title: "Sender"
            ActionItem {title: "Call"}
            ActionItem {title: "Send SMS"}
        }
    ]
}

 But, it doesn't state whether or not you can make one set active and deactivate the other.  Future feature?

 

When you create an ActionSet in c++, it doesn't seem like there is a way to add the OnTriggered function

ImageView* imageView = ImageView::create("john.png");
ActionSet* actionSet = ActionSet::create()
           .title("Email")
           .subtitle("From: John Doe")
           .add(ActionItem::create().title("Reply"))
           .add(ActionItem::create().title("Forward"));
imageView->addActionSet(actionSet);

 

Is there a way to add "onTriggered"?

Or, is there a way to determine which ActionItem was selected?

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Add onTriggered to c++ created ActionSet

[ Edited ]

It is a future feature and has been for a while now. Smiley Happy

 

Just add your onTriggered to the ActionItem...

 

ActionSet::create()
    .title(tr("Label style"))
    .subtitle(tr("Select an action."))
    .add(ActionItem::create()
            .onTriggered(this, SLOT(onMove()))
            .image(QUrl("asset:///images/actions/label_move.png"))
            .title(tr("Move")))

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: Add onTriggered to c++ created ActionSet

Would be nice if the documentation showed this.

Or at least show it in the example.

Thanks!
_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Add onTriggered to c++ created ActionSet

You mean like this...

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__abstractactionitem.html#func...

 

Smiley Happy

 

If you don't want to look back at the ancestor class then just click on the 'Show Inherited XXXXX' after each section in the inherited class.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Add onTriggered to c++ created ActionSet

Also while coding just entering a '.' will bring up all the auto-complete options, hovering over them will give you an explanation of what each function or inherited function will do.

 

It's all there for you really, you just have to know how to look. Half the battle I know. Smiley Happy

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: Add onTriggered to c++ created ActionSet

not to put us off topic but an even better method than '.' is holding ctrl and then clicking space

 

that will immidiately bring up the auto-complete window no matter what is typed, it's alot easier than having to wait on it to decide to pop up a few seconds after the '.'

Developer
Posts: 265
Registered: ‎01-02-2011
My Device: Z30, PlayBook
My Carrier: AT&T

Re: Add onTriggered to c++ created ActionSet

I had been to the AbstractActionItem page, but I guess I didn't find what I was looking for.

 

But, when I mean the example, I meant the example in the documenation that shows ActionSet with ActionItem with no "onTriggered".  They could have added it there as a hint.

 

Just sayin'.

_________________
Meetup for BlackBerry 10
Meetup Search Tool - not available at the moment
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Add onTriggered to c++ created ActionSet

[ Edited ]

@slashkyle Once again you missed the point. Smiley Happy

 

Putting the '.' in would have narrowed down the search to the Builder functions.

Which is what the OP had trouble finding.

 

Ctrl-Space gives you every possible valid entry at that position in the code.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 828
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: Add onTriggered to c++ created ActionSet

I see what you mean, so in correction to my previous statement after you place the '.' instead of waiting on the auto-complete window to pop up on its own you can force it open with ctrl + space.  (saves a few seconds every time) 

 

I was just trying to convey that ctrl + space is very useful Smiley Wink

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Add onTriggered to c++ created ActionSet

That I'll let you have. Smiley Wink


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.