Announcement

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

    UIBinder - Link multiple controls to the same event handler

    So I've got several tabs and a number of controls on each. When a user modifies the value of one of the controls I would like to enable a save button (which otherwise would be disabled).

    Is there anyway for me to link multiple controls to the same event handler, such as the value changed event?

    #2
    Hi mgallagher,

    I'm not perfectly sure here, but did you try to use handler objects instead of anonymous classes, so instead of:
    Code:
    widget1.addABCHandler(new ABCHandler() {
    	@Override
    	public void onABC(ABCEvent event) {
    		...
    		...
    	}
    });
    widget2.addABCHandler(new ABCHandler() {
    	@Override
    	public void onABC(ABCEvent event) {
    		...
    		...
    	}
    });
    use:
    Code:
    ABCHandler myHandler = new ABCHandler() {
    	@Override
    	public void onABC(ABCEvent event) {
    		...
    		...
    	}
    });
    widget1.addABCHandler(myHandler);
    widget2.addABCHandler(myHandler);
    widget3.addABCHandler(myHandler);
    ?

    Best regards,
    Blama

    Comment


      #3
      My thoughts exactly

      Great point. I guess what I was hoping was the ability to do something like this:

      Code:
      @UiHandler("txtOne, txtTwo, txtThree")
      public void onEditFieldClicked(RecordClickEvent e) {
          SC.say("Value changed");
      }

      Comment


        #4
        Here we go

        Worked it out.

        So if you want multiple controls to use the same handler with UIBinder this is how:

        Code:
        @UiHandler(value = {"txtText", "selType"})
        public void onEditFieldClicked(KeyDownEvent e) {
            SC.say("Key down!");
        }

        Comment

        Working...
        X