Java Code Examples for javafx.scene.layout.HBox#setOnMouseClicked()

The following examples show how to use javafx.scene.layout.HBox#setOnMouseClicked() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestCollectionComponent.java    From milkman with MIT License 6 votes vote down vote up
private Node createFolderEntry(Folder folder, Collection collection, TreeItem<Node> item) {
	Label folderName = new Label(folder.getName());
	HBox.setHgrow(folderName, Priority.ALWAYS);
	
	
	HBox hBox = new HBox(new FontAwesomeIconView(FontAwesomeIcon.FOLDER, "1.5em"), folderName);
	hBox.setOnMouseClicked(e -> {
		if (e.getButton() == MouseButton.PRIMARY) {
			item.setExpanded(!item.isExpanded());
			e.consume();
		}
		if (e.getButton() == MouseButton.SECONDARY) {
			folderCtxMenu.show(folder, collection, hBox, e.getScreenX(), e.getScreenY());
			e.consume();
		}
	});
	return hBox;
}
 
Example 2
Source File: RequestCollectionComponent.java    From milkman with MIT License 5 votes vote down vote up
private HBox createCollectionEntry(Collection collection, TreeItem<Node> item) {
	Label collectionName = new Label(collection.getName());
	HBox.setHgrow(collectionName, Priority.ALWAYS);
	
	
	
	JFXButton starringBtn = new JFXButton();
	starringBtn.getStyleClass().add("btn-starring");
	starringBtn.setGraphic(collection.isStarred() ? new FontAwesomeIconView(FontAwesomeIcon.STAR, "1em") : new FontAwesomeIconView(FontAwesomeIcon.STAR_ALT, "1em"));
	starringBtn.setOnAction( e -> {
		collection.setStarred(!collection.isStarred());
		//HACK invoke directly bc we want to trigger sorting (see further up).
		//this does not change the dirty-state as the 
		//dirty state in collection is not used any further
		collection.onDirtyChange.invoke(false, true);   

		starringBtn.setGraphic(collection.isStarred() ? new FontAwesomeIconView(FontAwesomeIcon.STAR, "1em") : new FontAwesomeIconView(FontAwesomeIcon.STAR_ALT, "1em"));
	});
	
	
	HBox hBox = new HBox(new FontAwesomeIconView(FontAwesomeIcon.FOLDER_ALT, "1.5em"), collectionName, starringBtn);

	
	hBox.setOnMouseClicked(e -> {
		if (e.getButton() == MouseButton.PRIMARY) {
			item.setExpanded(!item.isExpanded());
			e.consume();
		}
		if (e.getButton() == MouseButton.SECONDARY) {
			collectionCtxMenu.show(collection, hBox, e.getScreenX(), e.getScreenY());
			e.consume();
		}
	});
	return hBox;
}
 
Example 3
Source File: PanelMenuBar.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private HBox createNameArea() {
    HBox nameArea = new HBox();

    nameText = new Text(panelName);
    nameText.setId(IdGenerator.getPanelNameAreaId(panel.panelIndex));
    nameText.setWrappingWidth(NAME_DISPLAY_WIDTH);

    nameBox = new HBox();
    nameBox.getChildren().add(nameText);
    nameBox.setMinWidth(NAME_DISPLAY_WIDTH);
    nameBox.setMaxWidth(NAME_DISPLAY_WIDTH);
    nameBox.setAlignment(Pos.CENTER_LEFT);

    nameBox.setOnMouseClicked(mouseEvent -> {
        if (mouseEvent.getButton().equals(MouseButton.PRIMARY)
                && mouseEvent.getClickCount() == 2) {

            mouseEvent.consume();
            activateInplaceRename();
        }
    });
    Tooltip.install(nameArea, new Tooltip("Double click to edit the name of this panel"));

    nameArea.getChildren().add(nameBox);
    nameArea.setMinWidth(NAME_AREA_WIDTH);
    nameArea.setMaxWidth(NAME_AREA_WIDTH);
    nameArea.setPadding(new Insets(0, 10, 0, 5));
    return nameArea;
}
 
Example 4
Source File: SearchTextField.java    From arma-dialog-creator with MIT License 4 votes vote down vote up
/**
 Create a search text field with a provided {@link #textProperty()} change listener

 @param textPropertyListener change listener
 */
public SearchTextField(@Nullable ChangeListener<String> textPropertyListener) {
	setAlignment(Pos.CENTER_LEFT);

	tf = new TextField();
	tf.setStyle("-fx-background-color:transparent;-fx-background-radius: 0;");
	tf.setPadding(new Insets(5));

	tf.setPromptText(Lang.FxControlBundle().getString("SearchTextField.search"));
	ImageView imageView = new ImageView(SEARCH_ICON);
	StackPane stackPane = new StackPane(imageView);
	stackPane.setPadding(new Insets(5, 0, 5, 5));
	HBox hBox = new HBox(0, stackPane, tf);
	HBox.setHgrow(tf, Priority.ALWAYS);
	hBox.setCursor(Cursor.TEXT);
	hBox.setOnMouseClicked(new EventHandler<MouseEvent>() {
		@Override
		public void handle(MouseEvent event) {
			tf.requestFocus();
			tf.selectEnd();
			tf.deselect();
		}
	});
	getStyleClass().add(STYLE_CLASS);
	tf.focusedProperty().addListener(new ChangeListener<Boolean>() {
		@Override
		public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean focused) {
			if (focused) {
				if (!getStyleClass().contains(STYLE_CLASS_FOCUSED)) {
					getStyleClass().add(STYLE_CLASS_FOCUSED);
				}
			} else {
				getStyleClass().remove(STYLE_CLASS_FOCUSED);
			}
		}
	});
	getChildren().add(hBox);

	if (textPropertyListener != null) {
		textProperty().addListener(textPropertyListener);
	}
}