Announcement

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

    bringToFront

    Hello

    on button click I should do the following:
    1) show a "masking" canvas
    2) show a canvas
    3) bringToFront a button that opened this canvas.

    I noticed that if a button is inside layout, button.bringToFront() or button.setZIndex(10000000000) has no influence.

    Instead, I must invoke these methods on button's parent (and if a button is wrapped in 5 levels of parents, i should invoke getParent.getParent... 5 times).

    Code:
    private HLayout bottomLayout = new HLayout();
    bottomLayout.addMember(new MyButton());
    bottomLayout.show();
    
    
    public class MyButton extends Button {
    
        public MyButton(String name){
            super(name);
            setWidth(50);
    
            addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    Canvas mask = new Canvas();
                    mask.setWidth100();
                    mask.setHeight100();
                    mask.setBackgroundColor("#333333");
                    mask.setOpacity(60);
                    mask.setZIndex(10);
                    mask.bringToFront();
                    mask.show();
    
                    Label t = new Label();
                    t.setContents("label");
                    t.setBackgroundColor("red");
                    t.bringToFront();
                    t.show();
    
                    setBackgroundColor("blue");
                    getParentElement().bringToFront();
                }
            });

    How can I solve this?

    thank you
    Last edited by la123; 18 Jul 2010, 06:51.

    #2
    Why does the button need to be nested 5 levels deep? Is it used at another time?

    Comment


      #3
      The button is shown in a bit complex layout:
      on the second row (of vertical layout), on the right side (of horizontal layout), with other 2 buttons (inside a toolbar)

      That's 3 layouts. Too much to invoke bringToFront using getParent()*3

      Besides that, getParent()...getParent().bringToFront brings to front the whole layout, and not just the button that I need.


      thank you

      Comment


        #4
        well bringToFront() is based on an element's parents, not just the element. Is there any issue to having another button (exactly the same text/look/etc..) as the first, which isn't part of any layout, rather hidden till the event, then show(),bringToFront() on that button? That button could be in the exact same position as the actual one too.

        Comment


          #5
          thank you svjard, it solved the problem.

          Comment

          Working...
          X