Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    setCharacterCasing problem

    Hi!

    I have a problem with character casing on a TextItem. If I add a key press handler, character casing stops working, but If I remove the key press handler everything works fine. I was wondering if I'm missing something really obvious. I hope someone can help me, thanks.

    This is my code

    Code:
    txtNumero = new TextItem("numero", "Averiguacion");
    		txtNumero.setCharacterCasing(CharacterCasing.UPPER);
    		txtNumero.addKeyPressHandler(new KeyPressHandler() {
    			@Override
    			public void onKeyPress(KeyPressEvent event) {
    				if(event.getKeyName().equals("Enter"))
    					buscarDocumentosAveriguacion();
    			}
    		});

    #2
    Character casing uses the keypress handler to do the mapping. If you are not calling the super class instance, you are effectively removing the casing support.

    Comment


      #3
      How to call the super class instance?

      Originally posted by davidj6
      you are not calling the super class instance
      Thanks for replying.
      That's exactly my problem. I don't know how to call the superclass method since this is an anonymous class implementing an interface. Sorry about that, but I'm quite new to java as well.

      Could you please modify the above code so it calls the superclass method?

      Thanks again!

      Comment


        #4
        It turns out that overriding event handlers in SmartGWT disables the original functionality of the SmartClient handlers. In this case, the keyPress override doesn't allow the case conversion to occur.

        If you are just performing validation when Enter is pressed, maybe a keypress handler is not the best way to do that. One thought is to use the saveOnEnter setting for the form and handle the SubmitValues event. You don't actually have to submit anything but rather perform the validation. Just a thought.
        Last edited by davidj6; 9 Nov 2009, 06:55.

        Comment


          #5
          Why smartgwt overrides a handler instead of adding it?

          Originally posted by davidj6
          It turns out that overriding event handlers in SmartGWT disables the original functionality of the SmartClient handlers.
          If you are just performing validation when Enter is pressed
          Thanks for clarifying this though it's a shame it disables the Smartclient handlers. I think the handler should be just added not overridden.

          Sometimes we do validation when Enter is pressed but in this case we just fetch some data on a grid.
          There's a common requirement in our apps which is to change focus to the next control on Enter key press until they reach the last control on the form which in turn should perform an "action" (fetch data on a grid, submit values, etc.)
          So, how do you change focus on Enter key press while preserving the character casing, or any other setting, affected by the problem you described?

          The saveOnEnter and SubmitValues event combination could probably be used as a workaround though I haven't tested it.

          Again, thanks for your reply!

          Comment


            #6
            It's not generally true that adding handlers disables builtin functionality. There was a recent change in SVN that make keyPress cancellable, and getting it may resolve the problem you're seeing here.

            Comment

            Working...
            X