Threaded View

  1. #1
    Sencha User ITS_luka's Avatar
    Join Date
    Aug 2011
    Location
    Tbilisi, Georgia
    Posts
    19
    Vote Rating
    0
    ITS_luka is on a distinguished road

      0  

    Default Answered: About TextField

    Answered: About TextField


    Hello,

    onKeyPress, textfield must change character

    e.g. when i press 'a' on my keyboard, i want my textfield type 'პ'-symbol instead.

    I know unicodeCharCodes of my sybmols. (from \u4304 to \u4336)

    how to do that?

    thank you

  2. Ah. It wasn't clear where you were at in your development. This works nicely, if however unreasonably specific. The key is event.preventDefault() since you don't want the original character rendering, without this line, both characters will render:

    Code:
    public class TextFieldKeyPressTest implements EntryPoint
    {
       @Override
       public void onModuleLoad()
       {
          ContentPanel cp = new ContentPanel();
          cp.setPixelSize(400, 400);
    
          final TextField tf = new TextField();
          tf.addKeyPressHandler(new KeyPressHandler()
          {
             @Override
             public void onKeyPress(KeyPressEvent event)
             {
                event.preventDefault();
                char val = event.getCharCode();
                char swapChar = val;
                String current = tf.getText();
                if (val == 'a')
                {
                   swapChar = '\u00E4';
                }
    
                tf.setText(current + swapChar);
             }
          });
          cp.setWidget(tf);
    
          RootPanel.get().add(cp);
       }
    }

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar