Java 类javafx.scene.input.ContextMenuEvent 实例源码

项目:UDE    文件:Controller.java   
@FXML void initialize() {
    // Create ContextMenu
    settingsMenuItm.setOnAction(e -> { settings.showWindow(); });
    chngBckgrndMenuItem.setOnAction(e -> { settings.callBackgroundMngr(); });

    // Add MenuItem to ContextMenu
    contextMenu.getItems().addAll(settingsMenuItm, chngBckgrndMenuItem);

    // When user right-click on desktop
    desktopArea.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
       @Override
        public void handle(ContextMenuEvent event) {
            contextMenu.show(desktopArea, event.getScreenX(), event.getScreenY());
        }
    });

    settings.setsettingsImgView(backgroundImgView);
    backgroundImgView.setImage(settings.getBackgroundInfo());
    backgroundImgView.setFitWidth(1920); // Scale to view Note: need to do based on system parameters
    backgroundImgView.setFitHeight(1080);

    addIconTiles();
}
项目:jfreechart-fx    文件:ChartViewer.java   
/**
 * Creates a new viewer instance.
 * 
 * @param chart  the chart ({@code null} permitted).
 * @param contextMenuEnabled  enable the context menu?
 */
public ChartViewer(JFreeChart chart, boolean contextMenuEnabled) {
    this.canvas = new ChartCanvas(chart);
    this.canvas.setTooltipEnabled(true);
    this.canvas.addMouseHandler(new ZoomHandlerFX("zoom", this));
    setFocusTraversable(true);
    getChildren().add(this.canvas);

    this.zoomRectangle = new Rectangle(0, 0, new Color(0, 0, 1, 0.25));
    this.zoomRectangle.setManaged(false);
    this.zoomRectangle.setVisible(false);
    getChildren().add(this.zoomRectangle);

    this.contextMenu = createContextMenu();
    setOnContextMenuRequested((ContextMenuEvent event) -> {
        contextMenu.show(ChartViewer.this.getScene().getWindow(),
                event.getScreenX(), event.getScreenY());
    });
    this.contextMenu.setOnShowing(
            e -> ChartViewer.this.getCanvas().setTooltipEnabled(false));
    this.contextMenu.setOnHiding(
            e -> ChartViewer.this.getCanvas().setTooltipEnabled(true));
}
项目:WebPLP    文件:Main.java   
private ConsolePane createConsole()
{
    ConsolePane console = new ConsolePane();
    ContextMenu contextMenu = new ContextMenu();

    MenuItem clearConsoleItem = new MenuItem("Clear");
    clearConsoleItem.setOnAction(e -> console.clear());
    contextMenu.getItems().add(clearConsoleItem);

    console.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
        contextMenu.show(console, event.getScreenX(), event.getScreenY());
        event.consume();
    });
    console.setOnMouseClicked(event -> {
        if (event.getButton() == MouseButton.PRIMARY)
            contextMenu.hide();
    });

    return console;
}
项目:CalendarFX    文件:MonthSheetView.java   
/**
 * Constructs a new month sheet view that is using the {@link SimpleDateCell}.
 */
public MonthSheetView() {
    getStyleClass().add(DEFAULT_STYLE_CLASS);
    setHeaderCellFactory(param -> new MonthHeaderCell(param.getView(), param.getYearMonth()));

    /*
     * This view has its own context menu.
     */
    setContextMenu(createContextMenu());
    addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, evt -> {
        final PickResult pickResult = evt.getPickResult();
        final Node intersectedNode = pickResult.getIntersectedNode();
        if (intersectedNode != null && intersectedNode instanceof DateCell) {
            this.dateCell = (DateCell) intersectedNode;
        } else {
            this.dateCell = null;
        }

        ctxMenuScreenX = evt.getScreenX();
        ctxMenuScreenY = evt.getScreenY();
    });

    // Set the factory AFTER the context menu has been created or the cell factory
    // will be overridden again.
    setCellFactory(param -> new SimpleDateCell(param.getView(), param.getDate()));
}
项目:Gargoyle    文件:SystemLayoutViewController.java   
/********************************
 * 작성일 : 2016. 6. 11. 작성자 : KYJ
 *
 * 트리 컨텍스트 요청 이벤트
 *
 * @param event
 ********************************/
public void treeProjectFileOnContextMenuRequested(ContextMenuEvent event) {

    if (event.getSource() == treeProjectFile) {
        fileTreeContextMenu.hide();
        TreeItem<JavaProjectFileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
        if (selectedItem == null)
            return;

        tmpSelectFileWrapper = selectedItem.getValue();
        fileTreeContextMenu.show(treeProjectFile, event.getScreenX(), event.getScreenY());
    } else {
        fileTreeContextMenu.hide();
    }

}
项目:Shapify    文件:ContextEventHandler.java   
@Override
public void handle(ContextMenuEvent event) {
    GUIState guiState = mainController.getGUIController().getGuiState();

    if (!(event.getSource() instanceof Rectangle) || !((Rectangle) event.getSource()).isFocusOutline()) {
        if (event.getSource() instanceof Node) {
            guiState.setSelectedObject((Node) event.getSource());
        }

        FocusOutline focusOutline = guiState.getFocusOutline();
        Rectangle focusRectangle = focusOutline.getFocusRectangle();

        focusRectangle.fireEvent(event);
    }

    contextMenu.show(guiState.getSelectedObject(), event.getScreenX(), event.getScreenY());
}
项目:JttDesktop    文件:DualBuildWallContextMenuOpenerTest.java   
@Test public void shouldHideAndShowSingleInstance() {
   when( menu.friendly_isShowing() ).thenReturn( false, true, false, true );

   ContextMenuEvent event = new ContextMenuEvent( null, -1, -1, 0, 0, false, null );
   systemUnderTest.handle( event );

   verify( menu ).resetMenuOptions();
   verify( menu, times( 1 ) ).friendly_show( Mockito.any(), Mockito.anyDouble(), Mockito.anyDouble() );

   systemUnderTest.handle( event );

   systemUnderTest.handle( event );
   verify( menu, times( 2 ) ).resetMenuOptions();
   verify( menu, times( 2 ) ).friendly_show( Mockito.any(), Mockito.anyDouble(), Mockito.anyDouble() );

   systemUnderTest.handle( event );
   verify( menu, times( 2 ) ).resetMenuOptions();
   verify( menu, times( 2 ) ).friendly_show( Mockito.any(), Mockito.anyDouble(), Mockito.anyDouble() );
}
项目:Shapify    文件:ContextEventHandler.java   
@Override
public void handle(ContextMenuEvent event) {
    GUIState guiState = mainController.getGUIController().getGuiState();

    if (!(event.getSource() instanceof Rectangle) || !((Rectangle) event.getSource()).isFocusOutline()) {
        if (event.getSource() instanceof Node) {
            guiState.setSelectedObject((Node) event.getSource());
        }

        FocusOutline focusOutline = guiState.getFocusOutline();
        Rectangle focusRectangle = focusOutline.getFocusRectangle();

        focusRectangle.fireEvent(event);
    }

    contextMenu.show(guiState.getSelectedObject(), event.getScreenX(), event.getScreenY());
}
项目:shuffleboard    文件:WidgetPaneController.java   
private void createPaneContextMenu(ContextMenuEvent e) {
  MenuItem clear = FxUtils.menuItem("Clear", __ -> {
    List<Tile> tiles = new ArrayList<>(pane.getTiles());
    tiles.stream()
        .map((Function<Tile, Component>) pane::removeTile)
        .flatMap(Component::allComponents)
        .flatMap(TypeUtils.castStream(Sourced.class))
        .forEach(Sourced::removeAllSources);
  });
  ContextMenu contextMenu = new ContextMenu(clear);
  contextMenu.show(pane.getScene().getWindow(), e.getScreenX(), e.getScreenY());
}
项目:shuffleboard    文件:WidgetPaneController.java   
/**
 * Creates the context menu for a given tile.
 */
private ContextMenu createContextMenu(ContextMenuEvent event) {
  ContextMenu menu = new ContextMenu();

  LinkedHashMap<String, List<MenuItem>> actions = new LinkedHashMap<>();
  if (event.getTarget() instanceof Node) {
    Node leaf = (Node) event.getTarget();
    Stream
        .iterate(leaf, Node::getParent)
        // non-functional ugliness necessary due to the lack of takeWhile in java 8
        .peek(node -> ActionList.actionsForNode(node).ifPresent(al -> {
          if (actions.containsKey(al.getName())) {
            actions.get(al.getName()).addAll(al.toMenuItems());
          } else {
            actions.put(al.getName(), al.toMenuItems());
          }
        }))
        .allMatch(n -> n.getParent() != null); // terminates infinite Stream#iterate
  }

  actions.forEach((key, menuItems) -> {
    menu.getItems().add(new SeparatorMenuItem());
    menu.getItems().add(FxUtils.menuLabel(key));
    menu.getItems().addAll(menuItems);
  });

  // remove leading separator.
  menu.getItems().remove(0);

  return menu;
}
项目:arma-dialog-creator    文件:UICanvasEditor.java   
public UICanvasEditor(@NotNull Resolution resolution, @NotNull UICanvasConfiguration configuration, @NotNull CanvasDisplay<? extends CanvasControl> display) {
    super(resolution, display);

    setConfig(configuration);

    gc.setTextBaseline(VPos.CENTER);
    this.setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
        @Override
        public void handle(ContextMenuEvent event) {
            if (contextMenu != null) {
                Point2D p = getCanvas().localToScreen(contextMenuPosition.getX(), contextMenuPosition.getY());
                contextMenu.show(getCanvas(), p.getX(), p.getY());
            }
        }
    });

    absRegionComponent = new ArmaAbsoluteBoxComponent(resolution);
    selection.selected.addListener(new ListChangeListener<CanvasControl>() {
        @Override
        public void onChanged(Change<? extends CanvasControl> c) {
            requestPaint();
        }
    });

    getTimer().getRunnables().add(new Runnable() {
        @Override
        public void run() {
            prepaint();
        }
    });

    initializeSelectionEffect();
}
项目:JttDesktop    文件:FriendlyMenuOpener.java   
/**
 * {@inheritDoc}
 */
@Override public void handle( ContextMenuEvent event ) {
   if ( contextMenu.friendly_isShowing() ) {
      return;
   }

   contextMenu.friendly_show( display, event.getScreenX(), event.getScreenY() );
}
项目:JttDesktop    文件:DualBuildWallContextMenuOpener.java   
/**
 * {@inheritDoc}
 */
@Override public void handle( ContextMenuEvent event ) {
   if ( contextMenu.friendly_isShowing() ) return;

   contextMenu.resetMenuOptions();
   contextMenu.friendly_show( display, event.getScreenX(), event.getScreenY() );
}
项目:JttDesktop    文件:FriendlyMenuOpenerTest.java   
@Test public void shouldNotShowIfAlreadyShowing(){
   when( menu.friendly_isShowing() ).thenReturn( true );

   final double x = 394857.234;
   final double y = 2387.938;
   ContextMenuEvent event = new ContextMenuEvent( null, -1, -1, x, y, false, null );
   systemUnderTest.handle( event );

   verify( menu, never() ).friendly_show( Mockito.any(), Mockito.anyDouble(), Mockito.anyDouble() );
}
项目:JttDesktop    文件:FriendlyMenuOpenerTest.java   
@Test public void shouldShowIfNotShowing(){
   when( menu.friendly_isShowing() ).thenReturn( false );

   final double x = 394857.234;
   final double y = 2387.938;
   ContextMenuEvent event = new ContextMenuEvent( null, -1, -1, x, y, false, null );
   systemUnderTest.handle( event );

   verify( menu ).friendly_show( display, x, y );
}
项目:JttDesktop    文件:DualBuildWallDisplayImplTest.java   
@Ignore
@Test public void menuStressing() throws InterruptedException {
   DecoupledPlatformImpl.setInstance( new PlatformDecouplerImpl() );
   TestApplication.launch( () -> {
      systemUnderTest.setOnContextMenuRequested( new DualBuildWallContextMenuOpener( systemUnderTest ) );
      return systemUnderTest; 
   } );

   Random random = new Random();
   for ( int i = 0; i < 100000; i++ ) {
      EventHandler< ? super ContextMenuEvent > conextHandler = systemUnderTest.onContextMenuRequestedProperty().get();
   }

   Thread.sleep( 10000000 );
}
项目:JttDesktop    文件:DualBuildWallContextMenuOpenerTest.java   
@Test public void shouldPositionMenuAtMouseLocation() {
   final double x = 394857.234;
   final double y = 2387.938;
   ContextMenuEvent event = new ContextMenuEvent( null, -1, -1, x, y, false, null );
   systemUnderTest.handle( event );

   verify( menu ).resetMenuOptions();
   verify( menu ).friendly_show( display, x, y );
}
项目:JttDesktop    文件:DualBuildWallContextMenuTest.java   
@Test public void cancelShouldHideWhenUsingHeavySetup() throws InterruptedException{
   fullLaunch();
   PlatformImpl.runAndWait( () -> {
      opener.handle( new ContextMenuEvent( null, 0, 0, 0, 0, false, null ) );
   } );
   assertThat( systemUnderTest.friendly_isShowing(), is( true ) );
   PlatformImpl.runAndWait( () -> {
      retrieveMenuItem( CANCEL ).getOnAction().handle( new ActionEvent() );
   } );
   assertThat( systemUnderTest.friendly_isShowing(), is( false ) );
}
项目:jfiles    文件:ClientAppViewController.java   
/**
 * Context menu requested action.
 *
 * @param event
 *            the event
 */
@FXML
public void contextMenuRequested(ContextMenuEvent event) {
    Node node = event.getPickResult().getIntersectedNode();
    if (node == flowPane) {
        viewContextMenu.show(node, event.getScreenX(), event.getScreenY());
    } else if (node instanceof BorderPane) {
        fileContextMenu.show(node, event.getScreenX(), event.getScreenY());
    }
}
项目:RichTextFX    文件:GenericStyledAreaBehavior.java   
private void showContextMenu(ContextMenuEvent e) {
    ContextMenu menu = view.getContextMenu();
    double xOffset = view.getContextMenuXOffset();
    double yOffset = view.getContextMenuYOffset();

    menu.show(view, e.getScreenX() + xOffset, e.getScreenY() + yOffset);
}
项目:MineIDE    文件:TreeViewModeTab.java   
@Override
public void onRequestContext(final ContextMenuEvent event, final TreeItemIcon<String> source)
{
    System.out.println(source + " -> context");
}
项目:MineIDE    文件:TreeViewMode.java   
public void onRequestContext(final ContextMenuEvent event)
{
    TreeItemIcon<String> source = (TreeItemIcon<String>) this.getTree().getSelectionModel().getSelectedItem();
    this.onRequestContext(event, source);
}
项目:CalendarFX    文件:DateControl.java   
public ContextMenuParameterBase(ContextMenuEvent contextMenuEvent, DateControl dateControl) {
    this.contextMenuEvent = requireNonNull(contextMenuEvent);
    this.dateControl = requireNonNull(dateControl);
}
项目:CalendarFX    文件:DateControl.java   
public ContextMenuEvent getContextMenuEvent() {
    return contextMenuEvent;
}
项目:cassandra-client    文件:TablePanel.java   
private void onTableContextMenu(ContextMenuEvent event) {
    tableListView.getSelectedTable()
            .ifPresent(table -> tableContext.show(this, event.getScreenX(), event.getScreenY()));
}
项目:rpmjukebox    文件:AbstractTest.java   
protected ContextMenuEvent getContextMenuEvent(Object source) {
    return new ContextMenuEvent(source, null, ContextMenuEvent.CONTEXT_MENU_REQUESTED, 0, 0, 0, 0, false, null);
}
项目:fluidgrid    文件:MultiObjectPane.java   
@Override
public void addHandleContextMenu(EventHandler<ContextMenuEvent> event) {
    contextMenuEvents.add(event);
}
项目:fluidgrid    文件:MultiObjectPane.java   
@Override
public void handleContextMenu(ContextMenuEvent event) {
    for (EventHandler<ContextMenuEvent> h : contextMenuEvents) {
        h.handle(event);
    }
}
项目:JFoenix    文件:JFXListView.java   
private void initialize() {
    this.getStyleClass().add(DEFAULT_STYLE_CLASS);
    expanded.addListener((o, oldVal, newVal) -> {
        if (newVal) {
            expand();
        } else {
            collapse();
        }
    });

    verticalGap.addListener((o, oldVal, newVal) -> {
        if (isExpanded()) {
            expand();
        } else {
            collapse();
        }
    });

    // handle selection model on the list ( FOR NOW : we only support single selection on the list if it contains sublists)
    sublistsProperty.get().addListener((ListChangeListener.Change<? extends JFXListView<?>> c) -> {
        while (c.next()) {
            if (c.wasAdded() || c.wasUpdated() || c.wasReplaced()) {
                if (sublistsProperty.get().size() == 1) {
                    this.getSelectionModel()
                        .selectedItemProperty()
                        .addListener((o, oldVal, newVal) -> clearSelection(this));
                    // prevent selecting the sublist item by clicking the right mouse button
                    this.addEventFilter(ContextMenuEvent.CONTEXT_MENU_REQUESTED, Event::consume);
                }
                c.getAddedSubList()
                    .forEach(item -> item.getSelectionModel()
                        .selectedItemProperty()
                        .addListener((o, oldVal, newVal) -> clearSelection(item)));
            }
        }
    });

    // listen to index changes
    this.getSelectionModel().selectedIndexProperty().addListener((o, oldVal, newVal) -> {
        if (newVal.intValue() != -1) {
            updateOverAllSelectedIndex();
        }
    });
}
项目:systemdesign    文件:FXMLDrawingTab.java   
private MenuHints getHints() {
    Optional<ContextMenuEvent> event = Optional.ofNullable(lastContextMenuClick.get());
    return new MenuHints(event.map(e -> new Point2D(e.getX(), e.getY())));
}
项目:CalendarFX    文件:DateControl.java   
/**
 * Constructs a new context menu parameter object.
 *
 * @param evt       the event that triggered the context menu
 * @param control   the date control where the event occurred
 * @param entryView the entry view for which the context menu will be created
 */
public EntryContextMenuParameter(ContextMenuEvent evt, DateControl control, EntryViewBase<?> entryView) {
    super(evt, control);
    this.entryView = requireNonNull(entryView);
}
项目:CalendarFX    文件:DateControl.java   
/**
 * Constructs a new parameter object.
 *
 * @param evt         the event that triggered the context menu
 * @param dateControl the date control where the event occurred
 * @param calendar    the (default) calendar where newly created entries should
 *                    be added
 * @param time        the time where the mouse click occurred
 */
public ContextMenuParameter(ContextMenuEvent evt, DateControl dateControl, Calendar calendar, ZonedDateTime time) {
    super(evt, dateControl);
    this.calendar = requireNonNull(calendar);
    this.zonedDateTime = time;
}
项目:fluidgrid    文件:Selection.java   
@Override
public void handleContextMenu(ContextMenuEvent event) {

}
项目:fluidgrid    文件:DragAndDrop.java   
@Override
public void handleContextMenu(ContextMenuEvent event) {

}
项目:MineIDE    文件:TreeViewMode.java   
public abstract void onRequestContext(ContextMenuEvent event, TreeItemIcon<String> source);
项目:fluidgrid    文件:Extension.java   
void handleContextMenu(ContextMenuEvent event);
项目:fluidgrid    文件:MultiEventHandle.java   
void addHandleContextMenu(EventHandler<ContextMenuEvent> event);