Announcement

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

    Some Bugs with ClickEvents on DrawItems

    Hi
    i found two bugs concerning the clickevent on Drawitems (Drawrects). i attached the sample code so it's easy to check the behaviour.

    Bug 1:
    When you start the code you see three rects. a red, blue and a green one.
    blue overlapps the red one, and green overlaps the blue.
    when you click on this three rect each one is selected corret. the knobs will be displayed. and you see the bahviour is like you expect.

    But when you do...
    1. Now resize the red one just a few Pixel. Only that the resize Event was fired.
    2. Now click on the blue rect. When you click the blue rect in a region where is only the blue rect, then the blue rect is selected. But when you click the blue rect in a region where it overlaps the red one, the red is selected.


    Bug 2:
    try to select the rect on right side. This rect is not selectable, but the only difference is the
    m_oDR4.setLinePattern(LinePattern.DASH);
    This means, when a rect has not the pattern SOLID, then it isn't clickable anomore....


    Code:
    package ch.pmm.gwttest.client;
    
    /*
     * 1  Fall: Overlapping Problem
     * 2. Fall: Border mit ClickHandler
     * 3. Falle: In Version 4.1p wird der letzte DrawRect nicht clickbar gemacht 
     */
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.types.Cursor;
    import com.smartgwt.client.types.KnobType;
    import com.smartgwt.client.types.LinePattern;
    import com.smartgwt.client.types.Overflow;
    import com.smartgwt.client.widgets.drawing.DrawLabel;
    import com.smartgwt.client.widgets.drawing.DrawPane;
    import com.smartgwt.client.widgets.drawing.DrawRect;
    import com.smartgwt.client.widgets.drawing.events.DragResizeMoveEvent;
    import com.smartgwt.client.widgets.drawing.events.DragResizeMoveHandler;
    import com.smartgwt.client.widgets.drawing.events.MovedEvent;
    import com.smartgwt.client.widgets.drawing.events.MovedHandler;
    import com.smartgwt.client.widgets.events.DrawEvent;
    import com.smartgwt.client.widgets.events.DrawHandler;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class GWTTest implements EntryPoint {
        private DrawPane m_oDrawPane;
        private DrawRect m_oDR1 = null;
        private DrawRect m_oDR2 = null;
        private DrawRect m_oDR3 = null;
        private DrawRect m_oDR4 = null;
    
        public void onModuleLoad() {
            m_oDrawPane = new DrawPane();
            m_oDrawPane.setHeight(450);
            m_oDrawPane.setWidth(700);
            m_oDrawPane.setLeft(25);
            m_oDrawPane.setShowEdges(true);
            m_oDrawPane.setEdgeSize(4);
            m_oDrawPane.setBackgroundColor("papayawhip");
            m_oDrawPane.setOverflow(Overflow.HIDDEN);
            m_oDrawPane.setCursor(Cursor.AUTO);
            m_oDrawPane.addDrawHandler(new DrawHandler()
            {
              public void onDraw(DrawEvent drawEvent)
              {
                buildDrawPane(drawEvent);            
              }
            });
            VLayout layout = new VLayout();
            layout.addMember(m_oDrawPane);        
            layout.draw();
        }
        
        /****************************************************************************
         * buildDrawPane
         * @param event
         ***************************************************************************/
        private void buildDrawPane(DrawEvent event) {     
          DrawPane drawPane = (DrawPane) event.getSource();
      
          DrawLabel oDrawLabelBug1 = new DrawLabel();
          oDrawLabelBug1.setDrawPane(m_oDrawPane);            
          oDrawLabelBug1.setTop(10);
          oDrawLabelBug1.setLeft(50);
          oDrawLabelBug1.setContents("Bug 1");
          oDrawLabelBug1.draw();
          m_oDR1 = new DrawRect();
          m_oDR1.setID("m_oDR1_RED");
          m_oDR1.setDrawPane(drawPane);
          m_oDR1.setLeft(50);
          m_oDR1.setTop(50);
          m_oDR1.setWidth(150);
          m_oDR1.setHeight(100);
          m_oDR1.setCanDrag(true);
          m_oDR1.setFillColor("RED");
          m_oDR1.setFillOpacity(0.8f);
          addHandlersToDrawRect(m_oDR1);
          m_oDR1.draw();
      
          m_oDR2 = new DrawRect();
          m_oDR2.setID("m_oDR2_BLUE");
          m_oDR2.setDrawPane(drawPane);
          m_oDR2.setLeft(100);
          m_oDR2.setTop(100);
          m_oDR2.setWidth(150);
          m_oDR2.setHeight(100);
          m_oDR2.setCanDrag(true);
          m_oDR2.setFillColor("BLUE");
          m_oDR2.setFillOpacity(0.8f);
          addHandlersToDrawRect(m_oDR2);
          m_oDR2.draw();
          
          m_oDR3 = new DrawRect();
          m_oDR3.setID("m_oDR3_GREEN");
          m_oDR3.setDrawPane(drawPane);
          m_oDR3.setLeft(150);
          m_oDR3.setTop(150);
          m_oDR3.setWidth(150);
          m_oDR3.setHeight(100);
          m_oDR3.setCanDrag(true);
          m_oDR3.setFillColor("GREEN");
          m_oDR3.setFillOpacity(0.8f);           
          addHandlersToDrawRect(m_oDR3);
          m_oDR3.draw();
    
          DrawLabel oDrawLabelBug2 = new DrawLabel();
          oDrawLabelBug2.setDrawPane(m_oDrawPane);
          oDrawLabelBug2.setTop(10);
          oDrawLabelBug2.setLeft(350);
          oDrawLabelBug2.setContents("Bug 2");
          oDrawLabelBug2.draw();
          m_oDR4 = new DrawRect();
          m_oDR4.setID("m_oDR4_YELLOW");
          m_oDR4.setDrawPane(drawPane);
          m_oDR4.setLeft(350);
          m_oDR4.setTop(50);
          m_oDR4.setWidth(150);
          m_oDR4.setHeight(100);
          m_oDR4.setCanDrag(true);
          m_oDR4.setFillColor("YELLOW");
          m_oDR4.setFillOpacity(0.8f);
          m_oDR4.setLinePattern(LinePattern.DASH);
          addHandlersToDrawRect(m_oDR4);
          m_oDR4.draw();
        }
        
        /**********************************************************************************
         * addHandlersToDrawRects
         * @param oDrawRect
         * @param oContainer
         **********************************************************************************/
        private void addHandlersToDrawRect(final DrawRect oDrawRect) {
          
          //------------------------------------------------------------------------------------------
          oDrawRect.addClickHandler(new com.smartgwt.client.widgets.drawing.events.ClickHandler() {
            public void onClick(com.smartgwt.client.widgets.drawing.events.ClickEvent clickEvent)
            {
              System.out.println("DrawRect: onclick RectID: "+oDrawRect.getID());
              clickEvent.cancel();                 
              manageRectClick(oDrawRect);
            }
          });
          
          //-----------------------------------------------------------------------------------------------    
          oDrawRect.addDragResizeMoveHandler(new DragResizeMoveHandler() {
            @Override
            public void onDragResizeMove(DragResizeMoveEvent event)
            {       
              System.out.println("DrawRect: onDragResizeMove");         
            } 
          });
          
          //-----------------------------------------------------------------------------------------------    
          oDrawRect.addMovedHandler(new MovedHandler() {
            @Override
            public void onMoved(MovedEvent event)
            {
              System.out.println("DrawRect: onMoved");        
            }
          });
        }
        
        /******************************************************************************************
         * manageRectClick
         * Manages the current selected Rect by showing the move/resize knobs around
         * it
         * 
         * @param oDrawRect
         ******************************************************************************************/
        public void manageRectClick(final DrawRect oDrawRect)
        {            
            m_oDR1.hideKnobs(KnobType.RESIZE);
            m_oDR2.hideKnobs(KnobType.RESIZE);
            m_oDR3.hideKnobs(KnobType.RESIZE);
            oDrawRect.showKnobs(KnobType.RESIZE); 
        }
    }
    System: Win7
    Browser: FF 24.5
    SmartGWT 4.1 (Smart GWT LGPL Edition (2014-05-29 nightly))
    Attached Files
    Last edited by lmedici; 29 May 2014, 04:36. Reason: Systeminfos..

    #2
    The second issue is related to the fact that we have to manually draw dashed outlines (no native support in <canvas>). It's now fixed for all affected branches.

    The first issue is z-order related - we've fixed this for 4.1 and 5.0, but we do not currently plan to backport it further.

    Both fixes will be available in tomorrow's nightlies.

    Comment


      #3
      Originally posted by Isomorphic View Post
      The second issue is related to the fact that we have to manually draw dashed outlines (no native support in <canvas>). It's now fixed for all affected branches.

      The first issue is z-order related - we've fixed this for 4.1 and 5.0, but we do not currently plan to backport it further.

      Both fixes will be available in tomorrow's nightlies.
      Thank you very much! It works now fine.

      Comment

      Working...
      X