Announcement

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

    Canvas.setOpacity () affects container

    Issue
    I have a dialog containing a Canvas.
    When I call setOpacity () and setUseOpacityFilter () on the Canvas, the dialog itself becomes opaque, though I can see the Canvas.
    The second time I create the Dialog, the dialog is still opaque, and the Canvas is no longer visible.

    How to reproduce
    Run the example below.
    Click No Opacity as many times as you want.
    The dialog always appears normally: with a title, the close button, and a blue square.
    Click Opacity once.
    Instead of just the Canvas, the whole dialog appears opaque, the canvas is opaque, and the close button is clickable, but not visible.
    Click Opacity again.
    The dialog appears transparent, the canvas does not appear, and the close button is clickable, but not visible.
    See the attached screenshot to see what happens when I click No Opacity two times and then Opacity 2 times.

    The SmartGWT or SmartClient version and browser version(s) involved;
    SmartGWT 2.4
    Gwt 2.1.1
    Works in Chrome 10 dev mode.
    Does not work in IE 9 dev mode.
    Work in IE 9 production mode.

    Sample code.
    Code:
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.events.ClickEvent;
    
    import com.google.gwt.core.client.EntryPoint;
    
    public class TestSetOpacity  implements EntryPoint {
      
      /**
       * The EntryPoint interface
       */
      public void onModuleLoad () {
        
        // add a button that shows a dialog with a canvas with opaticy set
        final IButton button = new IButton ();
        button.setTitle ("Opacity");
        button.addClickHandler (new ClickHandler () {
          public void onClick (final ClickEvent clickEvent) {
            test (true);
          }
        });
        
        // add a button that shows a dialog with a canvas with no opaticy set
        final IButton button2 = new IButton ();
        button2.setTitle ("No Opacity");
        button2.addClickHandler (new ClickHandler () {
          public void onClick (final ClickEvent clickEvent) {
            test (false);
          }
        });
    
        // add
        final VLayout mainLayout = new VLayout ();
        mainLayout.addMember (button);
        mainLayout.addMember (button2);
        mainLayout.draw ();
      }
    
      /**
       * Runs the test
       * @param setOpacityFlag
       */
      private void test (final boolean setOpacityFlag) {
        
        // create Canvas with opacity
        final Canvas canvas = new Canvas ();
        canvas.setBackgroundColor ("blue");
        canvas.setLeft (100);
        canvas.setTop (100);
        canvas.setWidth (50);
        canvas.setHeight (50);
        if (setOpacityFlag) {
          canvas.setUseOpacityFilter (true);
          canvas.setOpacity (10);
        }
    
        // display in a Dialog
        final Window window = new Window ();
        window.setAutoSize (true);
        window.setShowMinimizeButton (false);
        window.setIsModal (true);
        window.setAutoCenter (true);
        window.addItem (canvas);
        window.show ();
      }
    }
    Any explanation/workarounds?
    Attached Files
Working...
X