Search code examples
gwtpopupmaskmasking

GWT: Masking a widget


I want to mask a widget. So i used a popup panel to do the same

public class MyMask extends PopupPanel
{
public MyMask ()
{
    super();
}

public void showAbsolute( UIObject uiObject )
{
    show();
    setPopupPosition( uiObject.getAbsoluteLeft(), uiObject.getAbsoluteTop() );
}

}

and my mask class looks like this

public final class Mask
{
private static MyMask mask = new MyMask();
private static UIObject object;

private Mask()
{
}

public static void enable( UIObject uiObject )
{
    VerticalPanel vp = new VerticalPanel();
    vp.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
    vp.setStyleName( "mask" );
    vp.setHeight( uiObject.getOffsetHeight() + Unit.PX.getType() );
    vp.setWidth( uiObject.getOffsetWidth() + Unit.PX.getType() );
    mask.add( vp );
    mask.showAbsolute( uiObject );
}

public static void disable()
{
    mask.hide();
}
}

But by calling

Mask.enable(widget)

The popup panel is not appearing exactly over the widget instead its coming below the widget and little bit towards the left. I want it to appear exactly on the widget. Any idea how to go about it?

Am currently using gwt 2.4.0

enter image description here


Solution

  • The solution is simple... No need of popup panel. Just change it disabled state and turn the background color to gray on mask and enable it, reapply the style on unmask