Thank you for visiting the BlackBerry Support Community Forums.
BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)
BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.
"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."
- Kevin Michaluk, Founder, CrackBerry.com
Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.
03-04-2010 12:37 PM
If I have a button and have written some code for it's invokeAction method, is it possible to call that button's invokeAction method from a menu item?
I suppose I could just copy the code for this button and add it to the menu; I'm really just wondering if there's an easier way.
(Sorry if this has already been covered in this forum, I'm not quite sure of the kinds of search terms I would use to find a solution to my question.)
Solved! Go to Solution.
03-04-2010 02:08 PM
invokeAction is protected, so you can't call it directly. You can play games like deriving a subclass with invokeAction made public. But it's usually simpler to just have the button's listener and the menu item's listener invoke a common method. That's easy and obvious if the listeners are in the same code module and a little more complicated if they're not, of course. But, in general duplicate code is a Bad Idea, and it's even worse if the duplicates are in different modules.