Thanks a lot for your answers....I will try it with the KeyUp Event,
sounds like this is what I should really use!!

On Oct 1, 10:01 am, Erik <[email protected]> wrote:
> You have to use KeyUp as mentioned before, because if you use
> KeyPress, the textbox still has its old value, in you case
>
> filterText.getText().trim() = old value = "AAA"
>
> String matchThis = filterText.getText().trim() + event.getCharCode() =
> "AAAB"
>
> If you use KeyUp, you use the new value in the textbox.
> in this case
>
> String matchThis = filterText.getText().trim() = "B"
>
> On Sep 30, 12:56 pm, ThomasWrobel <[email protected]> wrote:
>
> > I'm a bit confused why you dont just search for the whole text from
> > the filterText every time a key is pressed.
> > Surely thats what your effectively doing anyway by getting the current
> > text and adding the new characters?
>
> > Because the problem at the moment, if I'm understanding correctly, is
> > simply the filterText isnt being erased/reset when you want it to be.
>
> > Remember you can also use onKeyUp to get the state after the key is
> > pressed and released.
>
> > On Sep 30, 3:50 am, ojay <[email protected]> wrote:
>
> > > Hi,
>
> > > I have a textbox and a list of values in a listbox. Regarding of the
> > > input of the typed in value of the textbox the list will be filtered.
> > > I've managed this so far, but it's not working as expected. For
> > > example you typed in AAA then every value in the list which does not
> > > contain AAA will be removed. But when you mark all the AAA and type
> > > instead a B then my function will search for the string AAAB instead
> > > of only B. This happens because I am building this string on the
> > > keypresshandler, but if i do not build it like this I do not get
> > > actual textfield value and the new typed in character...
>
> > > Does anybody understand my problem and have a suggestion ?
>
> > > thanks
>
> > > public void onKeyPress(KeyPressEvent event) {
>
> > >                         filterFormList(filterText.getText().trim() + 
> > > event.getCharCode())
>
> > >         }
>
> > > public void filterFormList(String matchThis){
>
> > >                 ArrayList<Integer> toDeleteList = new 
> > > ArrayList<Integer>();
>
> > >                 for (int i = 0; i < formList.getItemCount(); i++){
> > >                         System.out.println("checking if " + matchThis
> > >                                         + " is found in " + 
> > > formList.getItemText(i));
>
> > >                         formList.getItemText(i).contains(matchThis);
>
> > >                         if (formList.getItemText(i).contains(matchThis)){
> > >                                 System.out.println("found it---adding 
> > > index " + i + " to delete
> > > list");
> > >                                 toDeleteList.add(new Integer(i));
> > >                         }
> > >                         else{
> > >                                 System.out.println("no match");
> > >                         }
> > >                 }
>
> > >                 for (Integer integer: toDeleteList){
> > >                         System.out.println("removing item " + 
> > > formList.getItemText
> > > (integer.intValue()));
> > >                         formList.removeItem(integer.intValue());
> > >                 }
>
> > >         }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to