Home > Enterprise >  Extend window size according to window caption/label in qooxdoo
Extend window size according to window caption/label in qooxdoo

Time:08-09

I have a window with a caption and two buttons. The window caption is longer than two buttons and I got three dots in the window caption. Is there some way to fix it I mean get rid of dots and see the full caption? Maybe try other ways for example use label in window body but I am afraid of the result will be the same.

var win = new qx.ui.window.Window("First Window");
win.setLayout(new qx.ui.layout.HBox());
win.setShowMinimize(false);

var yesBtn = new qx.ui.form.Button("Yes");
var noBtn = new qx.ui.form.Button("No");
win.add(yesBtn);
win.add(noBtn);

this.getRoot().add(win, {left:20, top:20});
win.open();

CodePudding user response:

You can set the minimum width of the window (win.setMinWidth(150), or you can add a spacer after the buttons (win.add(new qx.ui.core.Spacer(80));)

See this playground example: https://qooxdoo.org/qxl.playground/#{"code":"var%20win%20%3D%20new%20qx.ui.window.Window(%22First%20Window%22)%3B%0A%0Awin.setLayout(new%20qx.ui.layout.HBox())%3B%0Awin.setShowMinimize(false)%3B%0A%0Avar%20yesBtn%20%3D%20new%20qx.ui.form.Button(%22Yes%22)%3B%0Avar%20noBtn%20%3D%20new%20qx.ui.form.Button(%22No%22)%3B%0Awin.add(yesBtn)%3B%0Awin.add(noBtn)%3B%0A%0Athis.getRoot().add(win%2C%20%7Bleft%3A20%2C%20top%3A20%7D)%3B%0Awin.open()%3B%0A%0Alet%20option%20%3D%201%3B%0Aswitch(option)%0A%7B%0A%20%20case%201%20%3A%20%20%2F%2F%20This%20is%20likely%20your%20better%20option%0A%20%20%20%20win.setMinWidth(150)%3B%0A%20%20%20%20break%3B%0A%20%20%20%20%0A%20%20case%202%3A%20%20%20%2F%2F%20but%20this%20works%20too.%0A%20%20%20%20win.add(new%20qx.ui.core.Spacer(80))%3B%0A%20%20%20%20break%3B%0A%7D%0A%0A", "mode":"ria"}

CodePudding user response:

If a caption can have dynamic size for example is read from configuration files. The way is not use caption for these purposes and use label in window.

var win = new qx.ui.window.Window("First Window");
win.setLayout(new qx.ui.layout.VBox());
win.setShowMinimize(false);

var questionLabel = new qx.ui.basic.Label("Do you wanna sleep?");
win.add(questionLabel);

var container = new qx.ui.container.Composite(new qx.ui.layout.HBox());
var yesBtn = new qx.ui.form.Button("Yes");
var noBtn = new qx.ui.form.Button("No");
container.add(yesBtn);
container.add(noBtn);
win.add(container);

this.getRoot().add(win, {left:20, top:20});
win.open();
  • Related