Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Nebula NebulaSplitButton"

(Created page with "< Back to Nebula Main Page =Introduction= File:Breadcrumb.png This widget is a Push or Toogle Button with and attached menu. When the user clicks on the left...")
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
 
=Introduction=
 
=Introduction=
  
[[File:Breadcrumb.png]]
+
[[File:SplitButton.png]]
  
 
This widget is a Push or Toogle Button with and attached menu.
 
This widget is a Push or Toogle Button with and attached menu.
Line 30: Line 30:
 
And ''voilà'', it is done !
 
And ''voilà'', it is done !
  
The SolitButton API mimics the Button API. You can add selection listeners, change button state...
+
The SplitButton API mimics the Button API. You can add selection listeners, change button state...
  
 
=Examples=
 
=Examples=
  
An example called '''BreadcrumbSnippet.java''' is located in the plugin '''org.eclipse.nebula.widgets.opal.breadcrumb.snippets'''.
+
An example called '''SplitButtonSnippet.java''' is located in the plugin '''org.eclipse.nebula.widgets.splitbutton.snippets'''.
  
 
This example is also available here :
 
This example is also available here :
 
[https://raw.githubusercontent.com/eclipse/nebula/master/widgets/splitbutton/org.eclipse.nebula.widgets.splitbutton.snippets/src/org/eclipse/nebula/widgets/splitbutton/SplitButtonSnippet.java SplitButtonSnippet.java]
 
[https://raw.githubusercontent.com/eclipse/nebula/master/widgets/splitbutton/org.eclipse.nebula.widgets.splitbutton.snippets/src/org/eclipse/nebula/widgets/splitbutton/SplitButtonSnippet.java SplitButtonSnippet.java]

Revision as of 10:50, 9 December 2018

< Back to Nebula Main Page

Introduction

SplitButton.png

This widget is a Push or Toogle Button with and attached menu. When the user clicks on the left part of the button, the action (push or toggle) is performed. Otherwise, a menu is displayed

Usage

There is three steps : First, you instantiate a SplitButton object :

final SplitButton actionButton = new SplitButton(shell, SWT.NONE);

The style can be SWT.NONE or SWT.PUSH to create an instance of a Push button, or SWT.TOGGLE for a Toggle button.

Then you get the menu associated to this button :

 final Menu actionMenu = actionButton.getMenu();

And you add the items associated to this menu :

 final MenuItem item = new MenuItem(actionMenu, SWT.PUSH);
 item.setText("First menu item");
 item.addListener(SWT.Selection, e -> System.out.println("Click on menu item 'First menu item'"));

And voilà, it is done !

The SplitButton API mimics the Button API. You can add selection listeners, change button state...

Examples

An example called SplitButtonSnippet.java is located in the plugin org.eclipse.nebula.widgets.splitbutton.snippets.

This example is also available here : SplitButtonSnippet.java

Back to the top