Announcement

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

    TextItem.setWidth("100%") bug

    I have the following code in which TextItem.setWidth("100%") does not work correctly; Will this bug be fixed?
    Code:
    public class TestBug implements EntryPoint {
        public void onModuleLoad() {
            HTMLEditor editor = new HTMLEditor();
            editor.setWidth("70%");
            editor.setHeight("70%");
            editor.init();
            editor.draw();
        }
        class HTMLEditor extends Window {
            public HTMLEditor () {
    
            }
            public void init() {
                setTitle("editProperty");
                setRedrawOnResize(true);
                setShowMinimizeButton(false);
                setIsModal(true);
                setShowModalMask(true);
                setKeepInParentRect(true);
    
                VLayout panel = new VLayout(5);
                panel.setMargin(5);
                panel.setWidth("100%");
                panel.setHeight("100%");
    
                DynamicForm courseObjectForm = new DynamicForm();
                courseObjectForm.setWidth("100%");
                courseObjectForm.setCellPadding(5);
                courseObjectForm.setTitleAlign(Alignment.LEFT);
                courseObjectForm.setTitleSuffix(":");
    
                FormItemIcon editCourseObjectIcon = new FormItemIcon();
                editCourseObjectIcon.setSrc("[SKINIMG]actions/" + "edit.png");
                editCourseObjectIcon.setName("editCourseObjectIcon");
                editCourseObjectIcon.setPrompt("editCourseObject");
    
                StaticTextItem courseObjectValue = new StaticTextItem("courseObject", "course object");
                courseObjectValue.setWidth("100%");
                courseObjectValue.setIcons(editCourseObjectIcon);
                courseObjectValue.setWrapTitle(false);
                courseObjectForm.setFields(courseObjectValue);
                panel.addMember(courseObjectForm);
    
                DynamicForm form = new DynamicForm();
                form.setWidth("100%");
                form.setNumCols(2);
                form.setCellPadding(5);
                form.setCanHover(null);
                form.setShowHover(false);
                form.setTitleAlign(Alignment.LEFT);
                form.setTitleSuffix(":");
                panel.addMember(form);
    
                TextItem titleValue = new TextItem("title", "title title title title title");
                titleValue.setWrapTitle(false);
                titleValue.setWidth("100%");
                form.setFields(titleValue);
    
                RichTextEditor textValue = new RichTextEditor();
                textValue.setWidth("100%");
                textValue.setHeight("*");
                panel.addMember(textValue);
    
                Button cancelButton = new Button("cancel");
                Button saveButton = new Button("save");
    
                HLayout hLayout = new HLayout(5);
                hLayout.setAlign(Alignment.RIGHT);
                hLayout.setAutoHeight();
                hLayout.addMembers(cancelButton, saveButton);
                panel.addMember(hLayout);
    
                addItem(panel);
                show();
                centerInPage();
    
            }
        }
    
    }
    Click image for larger version

Name:	Zwischenablage-1.jpg
Views:	64
Size:	29.7 KB
ID:	268868
    Last edited by Hirn; 19 Oct 2022, 01:35.

    #2
    Please read the Form Layout overview. You are accepting the default colWidths which sets the title column at 100px. But you have a longer title than 100px and you have forced wrapping off. Therefore the long title causes horizontal overflow.

    Either allow wrapping, set a shorter title, increase the size of the title column, or turn on title clipping (dynamicForm.clipItemTitles).

    You can also auto-size the title column to the longest title of your form if you use offscreen rendering to determine the longest unwrapped title. The form doesn't do this for you automatically because it both has a performance impact and isn't clear if it's what you want (you can have a mixture of titles or other elements in that first column).

    Comment

    Working...
    X