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.
12-16-2008 10:52 PM
I've added a new item to the context menu in the email viewer screen and I want it to copy the selected text to the clipboard and then do something with it. It works fine if I manually copy the text by selecting and choosing 'copy' but I don't want the user to have to do that first and then choose my new menu item.
I'm trying to copy the selected text programmatically as suggested in this posting:
Looks like it should work but when I call isSelectionCopyable() on either the Screen or Field object I get a return of false. Calling selectionCopy() on either one does nothing also.
Any ideas how I can get around this?
12-17-2008 06:37 PM - edited 12-17-2008 06:37 PM
It's hard to deduce what you are doing and why it isn't working without a code snippet.
The thread you reference was somebody looking for a way to retreive text that was selected by the user. I think I understand that you want to select the text programmatically.
The select will always return false (for isCopyable) if there is no selection.
Have you tried maybe just calling getText() on the field? This should retrieve all of the text in the field, right?
12-17-2008 08:37 PM
Thanks for the reply! Actually I'm doing exactly what that person is doing, using the same code as presented in that message. I want the user to be able to select text and then activate my menu option and have it act on the text (via automatically copying to the clipboard first) without the user having to manually select the copy option first. I want only the selected text, not all of it.
I have created an application menu option using the following code:
ApplicationMenuItemRepository amir = ApplicationMenuItemRepository.getInstance();
My DemoMenuItem class extends ApplicationMenuItem as directed by the docs on extending application menus.
This all works and my menu item is called correctly when selected. It executes this code in the run() method of my DemoMenuItem object:
Screen s = UiApplication.getUiApplication().getActiveScreen()
Field fld = s.getFieldWithFocus();
For s I get an object of type
For fld I get an object of type
The fld object looks suspicious but regardless, calling isSelectionCopyable() or selectionCopy() on either the s or fld objects does not work as I indicated before.
12-18-2008 01:57 AM
That is weird. But you'd think that calling isSelectionCopyable() or selectionCopy() on the EmailEditorScreen object I have in s would do what I want. But no luck.
Does anyone know where I can find documentation on that object? Novice blackberry programmer here...
12-19-2008 11:44 AM
This approach isn't supported. However, your ApplicationMenuItem should receive a copy of the email message the user is writing as a parameter in its run method. You could read the text from here, display it on your own screen and allow the user to select the area you wish to work with.
You can then modify the message with the new text, call Message.updateUi to update the email message shown in the Messages application.