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


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.


Reply
New Contributor
Posts: 5
Registered: ‎08-09-2009
My Device: Not Specified

Is there any way to programatically invok blackberry "copy" menu on my menu?

[ Edited ]

Is there any way to programatically invok blackberry "copy" menu on my menu?

Thanks.

 

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

Re: Is there any way to programatically invok blackberry "copy" menu on my menu?

you can use getText on the field and call Clipboard.put to copy its contents into the clipboard. another option would be to list the menu items you have and call the run method on the correct one.
----------------------------------------------------------
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
New Contributor
Posts: 5
Registered: ‎08-09-2009
My Device: Not Specified

Re: Is there any way to programatically invok blackberry "copy" menu on my menu?

 


simon_hain wrote:
you can use getText on the field and call Clipboard.put to copy its contents into the clipboard.
My Code as below:
            Screen s = UiApplication.getUiApplication().getActiveScreen();
            if(s == null){
                return null;
            }
                
            Field fld = s.getLeafFieldWithFocus();
            if (fld != null && fld.isSelectionCopyable() != false) {
                Clipboard cd = Clipboard.getClipboard();
                fld.selectionCopy(cd);                
                Dialog.alert((String) cd.get());        
                cd.put(null);
            }                 
            but I can't get anything. thanks.


 

New Contributor
Posts: 5
Registered: ‎08-09-2009
My Device: Not Specified

Re: Is there any way to programatically invok blackberry "copy" menu on my menu?

 


simon_hain wrote:
another option would be to list the menu items you have and call the run method on the correct one.

 

         i tried run "copy" menu:

            ContextMenu cm=fld.getContextMenu();
        
            MenuItem[] mis = cm.getItems();
            
            //Dialog.alert(String.valueOf(MenuItem.COPY));
            
                        
            for(int i = 0; mis != null && i< mis.length; i++){
                //Dialog.alert(String.valueOf(i));
                //Dialog.alert("ID:"+String.valueOf(mis[i].getId())+" String:"+mis[i].toString());
                if(mis[i].toString().equalsIgnoreCase("COPY")){
                    Dialog.alert("will run copy...");
                    mis[i].run();                   
                }               
            }

 

         Clipboard cd = Clipboard.getClipboard();
            
         Dialog.alert("cp:"+(String) cd.get());

 

         the first i can't get anything, but the second i get the first selection.

Highlighted
Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: Is there any way to programatically invok blackberry "copy" menu on my menu?

Hi mengfanpp,

 

I run the desired menu in following way -

 

This gives me the active screen:

 

                net.rim.device.api.ui.Screen _scr = UiApplication.getUiApplication().getActiveScreen();

 

This gives me the menu of the screen:


                net.rim.device.api.ui.component.Menu _menu = _scr.getMenu(0);


This gives me the desired menuItem, which I need to execute, I need to pass the position of this menuItem to get the item:

 

               net.rim.device.api.ui.MenuItem _menuItem = _menu.getItem( 3 );

               _menuItem.run();

 

Best Regards,

Kanak Sony

 

 

 

 

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro