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
New Developer
xoheb
Posts: 14
Registered: ‎07-17-2008
My Device: Not Specified

TextField with autocomplete

Hi.

I want to create a text field with autocomplete feature. This feature is not "word prediction" but rather "suggests" names and addresses from the BB contacts. I know how to retrieve this information but implementing the "autocomplete" is the issue here.

 

Is there any support in the API for this? Or would I have to create a complete custom component?

 

 

Regards,

Xoheb.

Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: TextField with autocomplete

I have tried to create such a beast in the past, by overriding the various key methods (e.g. keyChar(..) for the input Field.  However for Sure Type phones, including the Storm, these key presses are swallowed by its auto-complete processing and you get told nothing until the user has finished inputting.  So I've yet to figure out how to do this on a Suretype phone.  If you are targeting those devices, then I suspect you are in for a bumpy ride.
New Developer
xoheb
Posts: 14
Registered: ‎07-17-2008
My Device: Not Specified

Re: TextField with autocomplete

I'm targeting 8800, Curve and Bold devices.
Developer
Guest
Posts: 146
Registered: ‎11-05-2008
My Device: Not Specified

Re: TextField with autocomplete

where u r facing the issue?After typing a character,with this char/string just match with addrebbok.And show the result on popup screen(layout can use).There is no api to implement this.Actually in this way i have done it and for non qwerty device,i have used keydown method. 
Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: TextField with autocomplete

Guest - What you are suggesting (using keyDown) seems to work for the first character, but after that you seem to loose control.  The sort of autocomplete I was trying to implement, required more than one character before the pattern matching was accurate enough to present a useful list to the User.  How do you suppress the standard autocomplete?

 

xoheb - the solution I was working towards was pretty much what Guest suggested. I would take the input string, then, if it matched sufficiently few of the possible options, I would supply the matched options in a pop-up that the user could choose from.  Not particularly elegant, and as noted, did not work for Suretype devices.  But it will work for the device types you are targeting.  I used keyChar.

New Developer
xoheb
Posts: 14
Registered: ‎07-17-2008
My Device: Not Specified

Re: TextField with autocomplete

Thanks for that Peter and Guest.

 

One more thing though... I need to make it look like autocomplete on a web browser for example... the suggestions appearing under the text field used for user input. I wonder how I can achieve that!

 

From what you're suggesting, I guess the results will be shown in a new popup window, right?

 

Regards,

Xoheb.

Developer
Guest
Posts: 146
Registered: ‎11-05-2008
My Device: Not Specified

Re: TextField with autocomplete

Hi peters,

no.I m right.I think,u couldn't understand it.This will not be created problem.Because,there will be a string,which will be by default nothing and,when he will be began to type ant character,this will be added to this string.and with this pattern it will be searched.And when backspace or dell will be,then string will be reduced naturally and at some point,the string will be nothing.

And with theresult  string  u have to create popup screen and have to implement listfield.

that's all

Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: TextField with autocomplete

xoheb - I am sure there are other options, but I did the pop-up screen.  I'm sure there are other options, for example, I suspect you could extend ListField to provide an input area and then populate the drop down.

 

Guest - I've just tested on standard 4.2 (Pearl) and 4.7 (Storm) and in both cases, once the Suretype processing has decided you are trying to type a word in, you have to 'escape' that processing to get keyDown to work again.  So the problem is not getting the String out of the input Field, the problem is getting control in a nice way.  keyChar and keyDown get control after every key press on the Qwerty devices, but on the Suretype input Fields, in my testing anyway, once the Suretype processing has grabbed control and is displaying its 'options', keyChar/keyDown will not get control until the user leaves this.

Developer
Guest
Posts: 146
Registered: ‎11-05-2008
My Device: Not Specified

Re: TextField with autocomplete

Ya.That's why i m explicitly called keyup function from keydown function.And for suretype it's working.
Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: TextField with autocomplete

OK, I'll give that a try.  Any other useful hints?  What do you return from your keydown?