当前位置: 首页>>代码示例>>Java>>正文


Java SWT.ARROW属性代码示例

本文整理汇总了Java中org.eclipse.swt.SWT.ARROW属性的典型用法代码示例。如果您正苦于以下问题:Java SWT.ARROW属性的具体用法?Java SWT.ARROW怎么用?Java SWT.ARROW使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.swt.SWT的用法示例。


在下文中一共展示了SWT.ARROW属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: widgetSelected

/**
 * Handle selection events.
 */	
public void widgetSelected(SelectionEvent event) {
	/**
	 * A selection event will be fired when a drop down tool
	 * item is selected in the main area and in the drop
	 * down arrow.  Examine the event detail to determine
	 * where the widget was selected.
	 */		
	if (event.detail == SWT.ARROW) {
		/*
		 * The drop down arrow was selected.
		 */
		if (visible) {
			// Hide the menu to give the Arrow the appearance of being a toggle button.
			setMenuVisible(false);
		} else {	
			// Position the menu below and vertically aligned with the the drop down tool button.
			final ToolItem toolItem = (ToolItem) event.widget;
			final ToolBar  toolBar = toolItem.getParent();
			
			Rectangle toolItemBounds = toolItem.getBounds();
			Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y));
			menu.setLocation(point.x, point.y + toolItemBounds.height);
			setMenuVisible(true);
		}
	} else {
		/*
		 * Main area of drop down tool item selected.
		 * An application would invoke the code to perform the action for the tool item.
		 */
	}
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:34,代码来源:DropDownSelectionListener.java

示例2: execute

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  // Sanity check.
  if (null == event) {
    return null;
  }

  // Class check.
  if (!(event.getTrigger() instanceof Event)) {
    return null;
  }

  final Event eventWidget = (Event) event.getTrigger();

  // Makes sure event came from a ToolItem.
  if (!(eventWidget.widget instanceof ToolItem)) {
    return null;
  }

  final ToolItem toolItem = (ToolItem) eventWidget.widget;

  // Creates fake selection event.
  final Event newEvent = new Event();
  newEvent.button = 1;
  newEvent.widget = toolItem;
  newEvent.detail = SWT.ARROW;
  newEvent.x = toolItem.getBounds().x;
  newEvent.y = toolItem.getBounds().y + toolItem.getBounds().height;

  // Dispatches the event.
  toolItem.notifyListeners(SWT.Selection, newEvent);

  return null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:34,代码来源:DropDownCommandHandler.java


注:本文中的org.eclipse.swt.SWT.ARROW属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。