Is there a standard SWT control that resembles a button which displays an arrow and opens a dropdown menu when pressed and is not a toolbar-only control?
It would be something like this:
It is similar to a combo box control, except that the "button" area would act more similarly to an actual button - its text would not change based on your selection, it would appear depressed when clicked, and the items would be used for actions or navigational purposes instead of for selection. It's also similar to a control available for toolbars, but I need to use it on a regular composite instead.
This is nearly doable simply by using regular button and popup-menu controls - however, I do not believe I can display the arrow next to the text on the button this way. Anyway, since this kind of control seems fairly common, I assumed there would be a standard way to use these two things as one.
This snippet shows how to use the described widget in a SWT toolbar. You can set the button text by using the
item.setText()
method.I think, this is what you should do get Drop down menu behavior
Menu
with styleSWT.DROP_DOWN
MenuItems
onMenu
if you want a button
SWT.ARROW | SWT.DOWN
SelectionListener
SelectionListener
, Create a Menu with styleSWT.POP_UP
and position the menu at the button location.//code