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

Java Development

Reply
Developer
Posts: 709
Registered: ‎09-10-2009
My Device: 8520, 8900, 9000, 9300, 9650, 9700, 9780, 9800, 9810, 9900, 9930
My Carrier: Verizon
Accepted Solution

Check marking a menu item

Anyone know how to put a check mark next to a menu item?

Developer
Posts: 17,011
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Check marking a menu item

i would suggest a custom menu (popupscreen with listfield). or maybe you find an unicode char you can use.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Check marking a menu item

I do this by faking it. I have two menu items, one with a check and one without. Inside makeMenu (or makeContextMenu), I decide which one to add to the menu based on the current state of the app.

 

The check itself is just a character. I tend to use Characters.BALLOT_BOX for the no-check version and Characters.BALLOT_BOX_WITH_CHECK for the checked version. The two characters take up about the same width, so the menu item doesn't seem to bounce around. (If you're putting this in a resource file, BALLOT_BOX is U+2610 and BALLOT_BOX_WITH_CHECK is U+2611.)




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: Check marking a menu item

Great suggestion, Ted - thanks!

 

Just a small addition: if you want to redisplay the message with/without checkmark when the user clicks that particular item (making them feel like they are "toggling" the flag), change whatever flag you need to change in its (item's) run method then invoke onMenu() of the screen you came from.  If that flag would have visual consequences (such as "Navigation Toolbar" in Mozilla), invalidate() the screen after changing that flag.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!