本文整理了Java中org.eclipse.swt.widgets.MenuItem.setAccelerator()
方法的一些代码示例,展示了MenuItem.setAccelerator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setAccelerator()
方法的具体详情如下:
包路径:org.eclipse.swt.widgets.MenuItem
类名称:MenuItem
方法名:setAccelerator
[英]Sets the widget accelerator. An accelerator is the bit-wise OR of zero or more modifier masks and a key. Examples: SWT.MOD1 | SWT.MOD2 | 'T', SWT.MOD3 | SWT.F2
. SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2
. The default value is zero, indicating that the menu item does not have an accelerator.
[中]设置小部件加速器。加速器是由零个或多个修改器掩码和一个键组成的逐位OR。示例:[$0$]。SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2
. 默认值为零,表示菜单项没有加速器。
代码示例来源:origin: pentaho/pentaho-kettle
@Override
public void widgetSelected( SelectionEvent e ) {
if ( e.detail == SWT.DROP_DOWN ) {
Menu menu = new Menu( shell, SWT.POP_UP );
MenuItem item1 = new MenuItem( menu, SWT.PUSH );
item1.setText( BaseMessages.getString( PKG, "Spoon.Run.Run" ) );
item1.setAccelerator( SWT.F9 );
item1.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e1 ) {
runTransformation();
}
} );
MenuItem item2 = new MenuItem( menu, SWT.PUSH );
item2.setText( BaseMessages.getString( PKG, "Spoon.Run.RunOptions" ) );
item2.setAccelerator( SWT.F8 );
item2.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e2 ) {
runOptionsTransformation();
}
} );
menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) );
menu.setVisible( true );
} else {
runTransformation();
}
}
} );
代码示例来源:origin: pentaho/pentaho-kettle
@Override
public void widgetSelected( SelectionEvent e ) {
if ( e.detail == SWT.DROP_DOWN ) {
Menu menu = new Menu( shell, SWT.POP_UP );
MenuItem item1 = new MenuItem( menu, SWT.PUSH );
item1.setText( BaseMessages.getString( PKG, "Spoon.Run.Run" ) );
item1.setAccelerator( SWT.F9 );
item1.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e1 ) {
runJob();
}
} );
MenuItem item2 = new MenuItem( menu, SWT.PUSH );
item2.setText( BaseMessages.getString( PKG, "Spoon.Run.RunOptions" ) );
item2.setAccelerator( SWT.F8 );
item2.addSelectionListener( new SelectionAdapter() {
@Override
public void widgetSelected( SelectionEvent e2 ) {
runOptionsJob();
}
} );
menu.setLocation( shell.getDisplay().map( mainComposite.getParent(), null, mainComposite.getLocation() ) );
menu.setVisible( true );
} else {
runJob();
}
}
} );
代码示例来源:origin: caoxinyu/RedisClient
mntmString.setAccelerator(SWT.ALT + '1');
mntmString.setImage(strImage);
mntmList.setAccelerator(SWT.ALT + '2');
mntmList.setImage(listImage);
mntmSet.setAccelerator(SWT.ALT + '3');
mntmSet.setImage(setImage);
mntmSortset.setAccelerator(SWT.ALT + '4');
mntmSortset.setImage(zsetImage);
mntmHash.setAccelerator(SWT.ALT + '5');
mntmHash.setImage(hashImage);
mntmcut.setEnabled(false);
mntmcut.setText(i18nFile.getText(I18nFile.CUT) + "\tCtrl+X");
mntmcut.setAccelerator(SWT.CTRL + 'X');
mntmCopy.setEnabled(false);
mntmCopy.setText(i18nFile.getText(I18nFile.COPY) + "\tCtrl+C");
mntmCopy.setAccelerator(SWT.CTRL + 'C');
mntmPaste.setEnabled(false);
mntmPaste.setText(i18nFile.getText(I18nFile.PASTE) + "\tCtrl+V");
mntmPaste.setAccelerator(SWT.CTRL + 'V');
mntmFind_2.setAccelerator(SWT.CTRL + 'F');
代码示例来源:origin: pentaho/pentaho-kettle
replaceItem.setText( OsHelper.customizeMenuitemText( BaseMessages.getString(
PKG, "WidgetDialog.Styled.Replace" ) ) );
replaceItem.setAccelerator( SWT.MOD1 | 'H' );
代码示例来源:origin: tvrenamer/tvrenamer
private void makeMenuItem(final Menu parent, final String text,
final Listener listener, final char shortcut)
{
MenuItem newItem = new MenuItem(parent, SWT.PUSH);
newItem.setText(text + "\tCtrl+" + shortcut);
newItem.addListener(SWT.Selection, listener);
newItem.setAccelerator(SWT.CONTROL | shortcut);
}
代码示例来源:origin: BiglySoftware/BiglyBT
/**
* Helper method to set a keyboard accelerator for a MenuItem. If kbInfo is SWT.NONE, no accelerator will be set.
* @param menu SWT MenuItem
* @param kbInfo KeyBindingInfo object, which contains the SWT accelerator value and its display name
*/
private static void setAccelerator(final MenuItem menu, final KeyBindingInfo kbInfo)
{
if ( menu.isDisposed()){
return;
}
if(kbInfo.accelerator != SWT.NONE)
{
menu.setAccelerator(kbInfo.accelerator);
// SWT on OS X now uses native drawing
if(!Constants.isOSX && !menu.getText().endsWith(kbInfo.name))
menu.setText(menu.getText() + kbInfo.name);
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
Menu createFileMenu() {
Menu bar = shell.getMenuBar ();
Menu menu = new Menu (bar);
MenuItem item;
// Open
item = new MenuItem (menu, SWT.PUSH);
item.setText (resources.getString("Open_menuitem"));
item.setAccelerator(SWT.MOD1 + 'O');
item.addSelectionListener(widgetSelectedAdapter(event -> openFile()));
// Exit
item = new MenuItem (menu, SWT.PUSH);
item.setText (resources.getString("Exit_menuitem"));
item.addSelectionListener (widgetSelectedAdapter(e -> menuFileExit ()));
return menu;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
item = new MenuItem(menu, SWT.PUSH);
item.setText(getMenuItemText("Push"));
if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + 'P');
if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciClosedFolder]);
item.setEnabled(enabledButton.getSelection());
item = new MenuItem(menu, SWT.CHECK);
item.setText(getMenuItemText("Check"));
if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + 'C');
if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciOpenFolder]);
item.setEnabled(enabledButton.getSelection());
item = new MenuItem(menu, SWT.RADIO);
item.setText(getMenuItemText("1Radio"));
if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + '1');
if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciTarget]);
item.setSelection(true);
if (acceleratorsButton.getSelection()) item.setAccelerator(SWT.MOD1 + SWT.MOD2 + '2');
if (imagesButton.getSelection()) item.setImage(instance.images[ControlExample.ciTarget]);
item.setEnabled(enabledButton.getSelection());
代码示例来源:origin: rinde/RinSim
playPauseMenuItem.setAccelerator(accelerators.get(MenuItems.PLAY));
playPauseMenuItem.addListener(SWT.Selection, new Listener() {
nextItem.setAccelerator(accelerators.get(MenuItems.NEXT_TICK));
nextItem.addListener(SWT.Selection, new Listener() {
@Override
zoomInItem.setAccelerator(accelerators.get(MenuItems.ZOOM_IN));
zoomInItem.setData(MenuItems.ZOOM_IN);
zoomOutItem.setAccelerator(accelerators.get(MenuItems.ZOOM_OUT));
zoomOutItem.setData(MenuItems.ZOOM_OUT);
.setAccelerator(accelerators.get(MenuItems.INCREASE_SPEED));
increaseSpeedItem.setText("Speed &up\tCtrl+]");
increaseSpeedItem.setData(MenuItems.INCREASE_SPEED);
decreaseSpeed.setAccelerator(accelerators.get(MenuItems.DECREASE_SPEED));
decreaseSpeed.setText("Slow &down\tCtrl+[");
decreaseSpeed.setData(MenuItems.DECREASE_SPEED);
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
item.setAccelerator(SWT.MOD1 + 'F');
item.addSelectionListener(widgetSelectedAdapter( e -> {
searchDialog.setMatchCase(false);
item.setAccelerator(SWT.F3);
item.addSelectionListener(widgetSelectedAdapter( e -> searchDialog.open()));
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
item.setAccelerator(SWT.MOD1 + 'O');
item.addSelectionListener(widgetSelectedAdapter(event -> menuOpenFile()));
item.setAccelerator(SWT.MOD1 + 'U');
item.addSelectionListener(widgetSelectedAdapter(event -> menuOpenURL()));
item.setAccelerator(SWT.MOD1 + 'L');
item.addSelectionListener(widgetSelectedAdapter(event -> menuLoad()));
item.setAccelerator(SWT.MOD1 + 'S');
item.addSelectionListener(widgetSelectedAdapter(event -> menuSave()));
item.setAccelerator(SWT.MOD1 + 'P');
item.addSelectionListener(widgetSelectedAdapter(event -> menuPrint()));
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
subItem.setAccelerator(SWT.MOD1 + 'N');
subItem.addSelectionListener(widgetSelectedAdapter( e -> newEntry()));
subItem = new MenuItem(menu, SWT.NONE);
subItem.setText(resAddressBook.getString("Edit_contact"));
subItem.setAccelerator(SWT.MOD1 + 'E');
subItem.addSelectionListener(widgetSelectedAdapter( e -> {
TableItem[] items = table.getSelection();
subItem.setAccelerator(SWT.MOD1 + 'B');
subItem.addSelectionListener(widgetSelectedAdapter( e -> {
if (closeAddressBook()) {
subItem.setAccelerator(SWT.MOD1 + 'O');
subItem.addSelectionListener(widgetSelectedAdapter( e -> {
if (closeAddressBook()) {
subItem.setAccelerator(SWT.MOD1 + 'S');
subItem.addSelectionListener(widgetSelectedAdapter( e -> save()));
subItem.setAccelerator(SWT.MOD1 + 'A');
subItem.addSelectionListener(widgetSelectedAdapter( e -> saveAs()));
代码示例来源:origin: openaudible/openaudible
item.setAccelerator(SWT.CTRL + equivalent);
name += " \tCtrl+" + equivalent;
} else {
item.setAccelerator(SWT.COMMAND + equivalent);
代码示例来源:origin: org.xworker/xworker_swt
item.setAccelerator(SwtUtils.getAccelerator(accelerator));
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
subItem.setAccelerator(SWT.MOD1 + 'E');
subItem.addSelectionListener(widgetSelectedAdapter( e -> {
TableItem[] items = table.getSelection();
subItem.setAccelerator(SWT.MOD1 + 'C');
subItem.addSelectionListener(widgetSelectedAdapter( e -> {
TableItem[] items = table.getSelection();
subItem.setAccelerator(SWT.MOD1 + 'V');
subItem.addSelectionListener(widgetSelectedAdapter( e -> {
if (copyBuffer == null) return;
代码示例来源:origin: org.xworker/xworker_swt
item.setAccelerator(SwtUtils.getAccelerator(accelerator));
代码示例来源:origin: org.codehaus.openxma/xmartclient
menuItemW.setAccelerator(item.getAccelerator());
代码示例来源:origin: org.codehaus.openxma/xmartserver
menuItemW.setAccelerator(item.getAccelerator());
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface
final MenuItem proxyItem = new MenuItem(proxy, realItem.getStyle());
proxyItem.setData(realItem);
proxyItem.setAccelerator(realItem.getAccelerator());
proxyItem.setEnabled(realItem.getEnabled());
proxyItem.setImage(realItem.getImage());
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface
final MenuItem proxyItem = new MenuItem(proxy, realItem.getStyle());
proxyItem.setData(realItem);
proxyItem.setAccelerator(realItem.getAccelerator());
proxyItem.setEnabled(realItem.getEnabled());
proxyItem.setImage(realItem.getImage());
内容来源于网络,如有侵权,请联系作者删除!