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

Adobe AIR Development

Reply
New Developer
Posts: 74
Registered: ‎02-09-2011
My Device: Torch 9850/64GB PlayBook
My Carrier: Verizon
Accepted Solution

Combobox not dispatching keyboard and no click event from the drop down.

I am using a ComboBox for a search in my application. The application is a Periodic Table so the user will be able to search by Element Name, Atomic Number, or Symbol. The  ComboBox is working great I just have two issues that I was wondering if someone could lead me in the right direction. The first problem is that when A user clicks the ComboBox to input a search, the keyboard does not dispatch. The user must use the native swipe gesture to display the keyboard. This isn't a huge problem but I would really like it to work so when the user clicks the ComboBox the Keyboard is dispatched. Iv'e looked into this and found that It should be working, Since the ComboBox does have a TextInput property the keyboard should come up but it doesn't. I also found out that there is no way to Show/Hide the keyboard with code. I am using FB 4.5 and Flex 4.5 and the newest BlackBerry Tablet SDK. Is there a bug or something? 

Also my other issue is once the user starts typing in the search the filter works great and the drop down displays all of the possibility's. But my only problem is the user cant just click and item in the drop down. For instance when the user types "A" all of the elements that start with A show up in the drop down. The user is unable to click an item. The only way the item can be selected is if the user keeps typing the word until it is highlighted as the only possibility and then hits enter. This too isnt a huge problem but I would like it to work so that if the user types "A" they can scroll through the drop down and select the item they want. Iv also looked into this and can't seem to find anyway to make the combobox's dropdown have a click event. I will put some code up later so you can see what I mean better, but for now its kind of a general questions. I am using FB 4.5 the release version and flex 4.5 with the newest BBT SDK. If any one can lead me in the right direction or send me any articles that would be GREAT. Thanks in advance!

  

New Developer
Posts: 74
Registered: ‎02-09-2011
My Device: Torch 9850/64GB PlayBook
My Carrier: Verizon

Re: Combobox not dispatching keyboard and no click event from the drop down.

Can I make a TextInput right over the ComboBox and set the transparency to 0. Then when the user clicks the ComboBox they really clicked the TextInput. This will then dispatch the keyboard and then I can make it run a function to change the GetFocus() to the ComboBox. Would this work?

Highlighted
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Combobox not dispatching keyboard and no click event from the drop down.

Probably will cause problems with how the persons selects. You might want to consider creating your own in this case and have a text input control that when gets focus, displays a list control underneath that it's data provider updates based on what you type into the text input control.
New Developer
Posts: 74
Registered: ‎02-09-2011
My Device: Torch 9850/64GB PlayBook
My Carrier: Verizon

Re: Combobox not dispatching keyboard and no click event from the drop down.

Thanks for the reply. I will look into that, It seems like it will be very in depth though. Do you know of any articles talking about this.

 

Thanks

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Combobox not dispatching keyboard and no click event from the drop down.

It is probably easier than you think:

  1. Create a text input control
  2. Add event listeners when the control changes ("change")
  3. Maintain an internal array of valid matches
  4. On the change event listener, traverse each item and do a match that makes senses.  For example, trim leading and trailing spaces and do a lower case string comparison on based on the length of the text input field.  For example, if the user types in "vel", that would match "developer" and "velcro".
  5. Create a List control that gets displayed once the person starts typing.  Position it below the text input control.  Use the local to global coordinate changes and size the width of the list to the same width of the text input.
  6. From #4, empty any data in the lists data provider and add items to it based on the string match.  If no matches or the text input text is blank/empty/null, dont show the list.
  7. If the user selects an item from the list, hide the list, enter the selection into the text input and then dispatch an event that the entry is "complete".
  8. Listen to the "complete" event of the text input to perform what ever you wanted.

Obviously, if someone can suggest how to get the Combox to work, go for it.  I just have a habbit to create controls to get the appearance and behavior I am looking for.

 

Good luck. 

New Developer
Posts: 74
Registered: ‎02-09-2011
My Device: Torch 9850/64GB PlayBook
My Carrier: Verizon

Re: Combobox not dispatching keyboard and no click event from the drop down.

Alright thank you so much cause yes that would solve both of my problems then so I think I am going to take your route. I thought it would be much more involved. Thanks for explaining it so nicely!

New Developer
Posts: 74
Registered: ‎02-09-2011
My Device: Torch 9850/64GB PlayBook
My Carrier: Verizon

Re: Combobox not dispatching keyboard and no click event from the drop down.

I did everything you said and its working fine except I am having some problems with my data provider. It seems like its not filtering properly and maybe not updating the arraycollection. When I first open the app and click in the textinput the list does show and I can scrool and click to an item. But when I start typing the listjust goes grey like there arent any items that meet that criteria. I put my code below if anyone can poingt out my problem. 

 

 

public var typedSmiley Frustratedtring;

private function typing():void{

if (ACList.visible == false){

ACList.visible = true;

}

}

private function filter(itemSmiley Surprisedbject):Boolean{

typed = AC.text;

if (elementArray.indexOf(typed) >= 0){

return true;}

else{return false;

}

}

private function filterSetup():void{

elementCollection.filterFunction = filter;

elementCollection.refresh();

ACList.dataProvider = elementCollection;

}

private function listClick():void{

AC.text = ACList.selectedItem.toString();

searchElement();

}

 

private function searchElement():void{

//code for what i do with AC.tex

private function toUC()Smiley Frustratedtring

var firstLetterSmiley Frustratedtring

var restOfWordSmiley Frustratedtring

if (AC.text.length == 1)

firstLetter = AC.text.charAt(0).toUpperCase();

return firstLetter;

}

else{

firstLetter = AC.text.charAt(0).toUpperCase();

restOfWord = AC.text.substr(1, AC.text.length);

return firstLetter + restOfWord;

}

}

 

<s:TextInput id="AC" x="155" y="81" width="195" height="30" fontFamily="Verdana" fontSize="14" editable="true" textInput="AC.text=toUC(), filterSetup()" focusIn="typing()" enter="searchElement()"/>

 

<s:List id="ACList" x="155" y="111" width="195" height="150" fontFamily="Verdana" fontSize="14" allowMultipleSelection="false" visible="false" click="listClick()">

   <s:dataProvider>

      <s:ArrayCollection id="elementCollection" filterFunction="{filter}">

         <fx:Array id="elementArray">

            <fxSmiley Frustratedtring>Actinium</fxSmiley Frustratedtring>

            \\and so on..

          </fx:Array>

      </s:ArrayCollection>

   </s:dataProvider>

</s:List>