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

Posts: 169
Registered: ‎03-25-2011
My Device: Playbook, Z10 L.E.
My Carrier: Vodafone NL

Help creating a new component: ToggleActionItem

Hello there,


I want to add toggle buttons as items of a Context Menu. The idea is that the user must be able to turn some functionalities on and off via the context menu of a component.

Right now I managed to implement this behavior just using the default Cascades components: I place some ActionItem on a ActionSet of contextActions of my component. Once the ActionItem is triggered I set some toggled flags true/false and change its title and imageSource property to represent the toggled state. If the user toggles another ActionItem from the contextMenu that's supposed to be another toggle button, I un-toggle the current toggled item first. It works fine, but I wish I could keep the down state of the item - blue background and while letters - as the toggled state.

But now I want to re-use this functionalities in other components but I'm not sure how to achieve this.


My first idea is as follows:

  • Extend the bb::cascades::ActionSet class to be a ToggleActionSet. It would have a custom boolean property named allowMultipleSelection that if set to true, multiple items could be toggled at the same time, if set to false, only one item would be possible to be selected. It would also contain a function getSelectedItems() that would return a list of selected indexes.
  • Extend the bb:cascades:ActionItem class to be a ToggleActionItem. It would contain one custom boolean property named toggledIt would contain the logic for rendering the toggled state (UI).
  • A bunch of signals and other functions are planned but I didn't put here just save some time.

What do you guys think? Do you think these two extended classes is the way to go?


I also checked the class bb::cascades::ImageToggleButton, which has a lot of the functionalities that I need, but it's not based on bb::cascades::AbstractActionItem so it's possible to put it in an ActionSet. The class bb::cascades::MultiSelectActionItem was also promising but I think it's meant to be used with something else, more complex than what I need.


Looking forward to your suggestions.