Announcement

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

    How to remove a Click handler from a canvas

    Hello,
    I am working on a piece of code that in one state needs a click handler like this:
    Code:
    mainCanvas.addClickHandler(new ClickHandler(){
    	
    				@Override
    				public void onClick(ClickEvent event) {
    					int x= event.getX();
    					int y=event.getY();
    					textCreate.setTop(y);
    					textCreate.setLeft(x);
    					textCreate.draw();
    				}
    			});
    but when the state changes i need to remove this click handler from the main canvas.
    I know that Canvas has this functionality:
    mainCanvas.getHandlerManager().removeHandler(type, handler)
    but I can't get it to work: what do i input for the type and the handler?

    Thanks!

    #2
    I also need to remove a handler from an item. In this case I need to remove a changedHandler.

    I do not see anything in the api like removeHandler(). What is the best way to accomplish this on a FormItem/SliderItem?

    Comment


      #3
      addClickHandler () is prototyped this way:
      Code:
      public HandlerRegistration addClickHandler(ClickHandler handler);
      So you should be able to do this:
      Code:
      final HandlerRegistration handlerRegistration = canvas.addClickHandler (clickHandler);
      // and later...
      handlerRegistration .removeHandler ();
      If this does not work, I would guess it's a bug.

      Comment


        #4
        shortpasta is correct (Thanks!)
        This functionality works for us - if it's not working for you on some specific build let us know (along with some sample code) and we'll take a look

        Regards
        Isomorphic Software

        Comment


          #5
          Works great

          Comment

          Working...
          X