I think you're adding a new keyboard listener to your table every time the onBrowserEvent method is called. That will end up being a lot of keyboard listeners.
Pascal On Feb 13, 3:53 pm, "sibopis...@googlemail.com" <sibopis...@googlemail.com> wrote: > Hello all, > > Please I’d appreciate if you could help me. I’ve got a FlexTable and > when I use left , right , up , down keyboard it changes the: > > cell’s board to read; > > show on a TexBox what keyboard was used. > > If enter it changes de cell’s text to the TexBox’s text > > All these are working. However, the performance get worse and worse > when the keyboards left , right , up , down and enter are used. The > more I used them , the more it increases the time to change the cell’s > text to the TextBox’s text, such as, 10 seconds and if I use the > keyboards more, it might increases to 15 , 20 seconds. > > Please help me to sort this performance’s problem > > Pires > > my Code: > > package com.sibopsoft.begin.client; > import com.google.gwt.core.client.EntryPoint; > import com.google.gwt.user.client.DOM; > import com.google.gwt.user.client.Element; > import com.google.gwt.user.client.Event; > import com.google.gwt.user.client.ui.KeyboardListener; > import com.google.gwt.user.client.ui.KeyboardListenerAdapter; > import com.google.gwt.user.client.ui.RootPanel; > import com.google.gwt.user.client.ui.VerticalPanel; > import com.google.gwt.user.client.ui.TextBox; > import com.google.gwt.user.client.ui.FlexTable; > import com.google.gwt.user.client.ui.Widget; > > public class Test extends VerticalPanel implements EntryPoint { > TextBox tb = new TextBox(); > FlexTable t = new FlexTable(); > int l=0; > int c=0; > > public void onModuleLoad() { > > t.setBorderWidth(1); > t.setCellSpacing(5); > > for (int i=0 ; i<15 ; i++) > > for (int j=0 ; j<15 ; j++) > > t.setText(i,j, "KAKA"); > > add(tb); > add(t); > > sinkEvents(Event.KEYEVENTS); > RootPanel.get().add(this); > > } > public void onBrowserEvent(Event e) { > > int type = DOM.eventGetType(e); > Element el = DOM.eventGetFromElement(e); > > if ( type == Event.ONKEYDOWN ) { > > if ( KeyboardListener.KEY_RIGHT == > DOM.eventGetKeyCode > (e) ) { > tb.setText("KEY_RIGHT"); > t.getFlexCellFormatter().setStyleName(l, c+=1, > "FlexTable-Cell-Red"); > t.getFlexCellFormatter().setStyleName(l, c-1, > "FlexTable-Cell-Black"); > } > > if ( KeyboardListener.KEY_LEFT == DOM.eventGetKeyCode > (e) ) { > tb.setText("KEY_LEFT"); > t.getFlexCellFormatter().setStyleName(l, c-=1, > "FlexTable-Cell-Red"); > t.getFlexCellFormatter().setStyleName(l, c+1, > "FlexTable-Cell-Black"); > } > if ( KeyboardListener.KEY_UP == DOM.eventGetKeyCode(e) ) > { > tb.setText("KEY_RIGHT"); > t.getFlexCellFormatter().setStyleName(l-=1, c, > "FlexTable-Cell-Red"); > t.getFlexCellFormatter().setStyleName(l+1, c, > "FlexTable-Cell-Black"); > } > > if ( KeyboardListener.KEY_DOWN == DOM.eventGetKeyCode > (e) ) { > tb.setText("KEY_LEFT"); > t.getFlexCellFormatter().setStyleName(l+=1, c, > "FlexTable-Cell-Red"); > t.getFlexCellFormatter().setStyleName(l-1, c, > "FlexTable-Cell-Black"); > } > > } > tb.addKeyboardListener(new KeyboardListenerAdapter() { > public void onKeyDown(Widget sender, char keyCode, int > modifiers) { > if (keyCode == (char) KEY_ENTER) > > t.setText(l, c, tb.getText()); > > } > }); > > } > > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---