Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  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);
       }
    }

  3. #2
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    Have you looked at TextField.addKeyPressHandler(...)?

  4. #3
    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


    Yes, but its not as easy as it seems

  5. #4
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      1  

    Default


    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);
       }
    }

  6. #5
    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


    Thank you.

    Your reply helped me.

    but I have a question:

    what is the difference between setText()/getText() and setValue()/getValue() methods?

  7. #6
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    You're welcome. I believe get/set Value have to do with focus, i.e. getValue won't return the actual, displayed value (which is what getText does) until a blur event is fired.

    I attempted to verify this but getValue is always returning null because it appears that setText does not update the internal value reference. I am still working on this and don't have an answer yet.

  8. #7
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    The difference is that getValue only returns the actual displayed value when an onBlur event is fired. Since we're calling preventDefault(), this event is not propagated which means getValue will never return anything but null (assuming an initially empty text field).

    setValue updates the internal value field and fires a value change event if the new value is different from the old value. Essentially, setValue gives you the opportunity to do more event handling control, e.g., preventing updates to the field from firing events.

    Using setValue to set the field's value this example will actually cause the text field's focus to be lost because of the underlying call to redraw(). Some work arounds would be to call focus() again but then you'd have to set the correct cursor position, or you could not call preventDefault() but then you'd need to get/use the current selection range to replace the extra character.

    But bottom line, if you don't have any other handlers on this text field, don't care about any other event propagation, and are sure you are consistent in calling getText instead of getValue, there's nothing wrong with keeping the preventDefault() and calling setText.

  9. #8
    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


    Thank you icfantv. Everything is clear
    I T S

Thread Participants: 1