ToolbarButton - Insufficient width for caption - vaadin

I want to add a caption to a toolbar button (with an icon) because if the button is grayed out (disabled) the description is not displayed.
Caption is also displayed if the button is not enabled...
My problem is that I can't figure out how to enlarge the ToolbarButton field to fit the caption.
The caption consists of 3 words and currently only the first word is displayed due to lack of space - relevant code snippet:
toolbarButton = new ToolbarButton();
toolbarButton.setIcon(ImgRes.ICON_PREVIEW);
toolbarButton.setDescription("Preview Button Description");
toolbarButton.setCaption("Preview Button Caption");
toolbarButton.setWidth("100%");
toolbarButton.setEnabled(false);
toolbarButton.addClickListener(e -> onPreviewButtonClicked());
return toolbarButton;
}
Can anyone help me how to solve my problem?

Try to set the min-width of the button so that it will always fit the content inside it:
toolbarButton.setMinWidth("max-content");

Related

Add dropdown button to component

I want to add a dropdown button which usually works as an expand / collapse button in a treegrid. I can't seem to find in the documentation how to add a button which is the exact width and height of the dropdown button, e.g. the specific (custom) button class. This dropdown button should be added to a cell component even if it cannot be expanded / collapsed. The outcome should be that the button in the circle should also be present in the place of the x marks.
I am not fully sure in which context you are going to use this button, but here is an example of borderless button, with html caption that uses the same styles than TreeGrid uses for collapse button.
Button btn = new Button();
btn.addStyleNames("v-treegrid-expander","collapsed");
btn.addStyleName(ValoTheme.BUTTON_BORDERLESS);
btn.addClickListener(event -> {
btn.removeStyleName("collapsed");
btn.addStyleName("expanded");
});
layout.addComponent(btn);

In Delphi, how can I make a button appear on top of a TCheckListBox?

We want a list box with check boxes and formatted text. We get that using a TCheckListBox in owner-draw mode.
But we would like to also have a button appear at the right end of the selected row. Just adding a button (TSpeedButton) with the CheckListBox as the Parent doesn't get drawn correctly.
Does anyone know how to do this?

Dart: onContextMenu position misplaced

I have a problem with mouse right click menu. My web app has left navigation div, toolbar div, and contentView div. contentView div shows all of my contents /works kind of like web within web/. So here the problem begins. I created onContextMenu on my table like this:
tr.onContextMenu.listen((e) {
contextMenu.style.display = 'block';
contextMenu.style.left = "${e.page.x}px";
contextMenu.style.top = "${e.page.y}px";
selectedRow.clear();
selectedRow.add(tr);
});
When i click right button it takes the position from whole window but when it shows the context menu, the position is based on contentView div. For example if my mouse position is (200,200) it's like (wholepage.0+200,wholepage.0+300) and context menu position would be around (400,500) which is like (contentView div.0+200,contentView div.0+300).
So how can i show my context menu at where mouse is clicked?
Try
contextMenu.style.left = "${e.client.x}px";
contextMenu.style.top = "${e.client.y}px";
and dont forget absolute positioning.
Regards Robert
Well i just changed
${e.page.x}px;
${e.page.y}px;
to
${e.layer.x}px;
${e.layer.y}px;
and now it works.

SpTBX: make a button in Panel caption (near [x])

I'm asked to add a btn near the TSpTbxDockablePanel's [x] icon. Can I do it? Btn may look like this, note that wider button is better. (I need custom title or icon, and OnClick for it).
Items property of dockable panel allows to add any items TSpTbxItem to caption. Can edit Items while in design mode.

How to set the glyph for a toolbar button to blank?

I add a toolbar with some standard Delphi components to my application. Unfortunately, the stupid arrow is first glyph (does anyone even know what it is for?)
I would like to destroy it totally, or, at least, set itcs icon to blank, so that it blends in with the toolbar.
How can I do this?
I need some code which can be executed twice without causing an exception. Thanks
TToolButton gets its image from combining its ImageIndex property with the enclosing toolbar's Images property, which refers to a TImageList. To make a toolbar button have no image, assign ImageIndex := -1.
To remove the glyph from a TSpeedButton at design time, select the button, and then select the Glyph property in the Object Inspector. Press Del to clear the property. To do the same at run time, assign Button.Glyph := nil.
If you have a pre-made toolbar, such as TMediaPlayer or TDBNavigator, then you can't customize the buttons. They always show the arrow glyphs that are hard-coded in the control. You can choose to hide or show certain buttons, though. If you placed the control just to get a row of buttons and have no intention of using them to play media or navigate a database, then don't use that control. Just place a TPanel and put standalone buttons on it.

Resources