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
Contributor
Posts: 17
Registered: ‎04-09-2012
My Device: BB9900
My Carrier: 02

Getting text from start selection

I want an ApplicationMenuItemRepository.MENUITEM_SYSTEM to check that some text has been selected i.e. when user clicks menu button and then start selection, get the text before starting my application. 

 

My question is how do I detect a selection has been made and how do I get the text?

 

 

Thanks

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Getting text from start selection

Are you talking about text on the clipboard?

 

You get an instance of the Clipboard and retrieve the text. See Clipboard in the javadocs.

 

Developer
Posts: 206
Registered: ‎02-22-2011
My Device: BB TORCH & 9800
My Carrier: idea

Re: Getting text from start selection

you mean , for suppose in TextField some text has been entered, the entered text should select from start to end like that.

is this your requirement?
*****************************************************************************
* Give kudos when you like it
* Mark it as a solution if it fixes your issue
Developer
Posts: 19,624
Registered: ‎07-14-2008
My Device: Not Specified

Re: Getting text from start selection

Never done this in practice, but this is how I would try to do it. 

 

I think the first thing you are going to have to do is find out what Field has focus

 

UiApplication.getUiApplication().getActiveScreen(), will get you the screen,

 

<screen>.getLeafWithFocus()  will get you the Field that has focus.

 

Now you want to check that the user is actually selecting in that Field

 

<field>isSelecting() && <field>.isSelectionCopyable()

 

if so, the copy to the Clipboard:

 

<field>.selectionCopy()

 

and pick up what you want from the Clipboard.

 

Alternatively, just make sure there is something in the Clipboard and use that, tell the use to put something these if not.