Announcement

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

    Help with setting widget position

    Using SmartGWT 2.3
    Browser FF3

    SetLeft is not working?!!!

    I'm trying to perform what I'd think be a super simple operation, but it's not working at all! Simply trying to position my widget (which exists inside other widgets) to appear in a certain position with top and left "margins".

    However for the life of me I can't figure it out. I've tried using setLeft and setRect but they won't move my widget at all. I've tried this on an IButton and also wrapping it inside a plain-jane Canvas.

    Code:
    public class somePane extends VLayout {
    
        private static final int WIDTH = 500;
        
        public GuimapPane() {
            super(10);
            this.setWidth(WIDTH);
            
            ...form...
            
            IButton submit = new IButton();
            submit.setTitle("Submit");
            submit.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    form.setShowInlineErrors(true);
                    if (form.validate()) {
                        form.setSaveOperationType(DSOperationType.ADD);
                        form.saveData();
                    }
                }
            });
            
            Canvas canvasButtons = new Canvas();
            canvasButtons.setLeft(100);
            canvasButtons.addChild(submit);
            
            this.addMember(form);
            this.addMember(canvasButtons);
        }
    }
    I've attached screen shot of what I mean.
    Attached Files

    #2
    Widgets added to a Layout have their position managed by that Layout. To create offsets, use membersMargin, layoutMargin, canvas.extraSpace and similar properties.

    To use absolute positioning, add the Canvas to another Canvas instead, or add it as a child of the Layout (addChild()) rather than as a member of the layout (addMember()).

    Comment


      #3
      Thanks for reply!

      I changed it to the following. Let me know if you would not consider this appropriate and there is a better way.

      Code:
              HLayout canvasButtons = new HLayout();
              canvasButtons.setLayoutLeftMargin(100);
              canvasButtons.setMembers(submit);
              
              this.addMember(form);
              this.addMember(canvasButtons);
      Cheers

      Comment

      Working...
      X