Results 1 to 2 of 2

Thread: HandlesAllKeyEvents onKeyPress() / onKeyDown() / onKeyUp()

  1. #1

    Default HandlesAllKeyEvents onKeyPress() / onKeyDown() / onKeyUp()

    HandlesAllKeyEvents onKeyPress() / onKeyDown() / onKeyUp(), from no where I can access the text entered in the TextField/PasswordField. In above method I can get only the old text. Please help me get the updated text on keyEvent.

  2. #2
    Sencha Premium Member
    Join Date
    Jun 2013
    Location
    Nuremberg, Germany
    Posts
    88
    Answers
    3

    Default

    Hi,

    we are validating the entered text in a date picker by overriding the onKeyUp method. Perhaps it's the way you read the entered text that doesn't show you the current text.

    Try this:
    Code:
    @Override
    protected void onKeyUp(Event e) {
    
        DateCell dc = this.getCell();
        String text = dc.getText(getElement()); // this is the current text
    }
    For a text area we check the current text lenght this way:
    Code:
    @Override
    public void onKeyUp(Event event) {
        super.onKeyUp(event);
    
        if (maxlength == -1)
            return;
    
        String text = getInputEl().getInnerText();
        if (text.length() > maxlength)
            getInputEl().setInnerText(text.substring(0, maxlength));
    }
    I hope this helps!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •