當前位置: 首頁>>代碼示例>>Java>>正文


Java MouseEvent.getTarget方法代碼示例

本文整理匯總了Java中javafx.scene.input.MouseEvent.getTarget方法的典型用法代碼示例。如果您正苦於以下問題:Java MouseEvent.getTarget方法的具體用法?Java MouseEvent.getTarget怎麽用?Java MouseEvent.getTarget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.input.MouseEvent的用法示例。


在下文中一共展示了MouseEvent.getTarget方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: performSelection

import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void performSelection(MouseEvent evt) {
    if ((evt.getButton().equals(PRIMARY) || evt.isPopupTrigger()) && evt.getClickCount() == 1) {

        Entry<?> entry;
        EntryViewBase<?> view = null;

        if (evt.getTarget() instanceof EntryViewBase) {
            view = (EntryViewBase<?>) evt.getTarget();
        }

        if (view == null) {
            return;
        }

        String disableFocusHandlingKey = "disable-focus-handling"; //$NON-NLS-1$

        view.getProperties().put(disableFocusHandlingKey, true);
        view.requestFocus();

        entry = view.getEntry();

        if (entry != null) {

            if (!isMultiSelect(evt) && !getSelections().contains(entry)) {
                clearSelection();
            }

            if (isMultiSelect(evt) && getSelections().contains(entry)) {
                getSelections().remove(entry);
            } else if (!getSelections().contains(entry)) {
                getSelections().add(entry);
            }
        }

        view.getProperties().remove(disableFocusHandlingKey);

    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:39,代碼來源:DateControl.java

示例2: startDrag

import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void startDrag(MouseEvent evt) {
    EventTarget target = evt.getTarget();
    if (isScrollBar(target) || !isOnEntry(target)) {
        return;
    }
    Dragboard db = startDragAndDrop(TransferMode.MOVE);
    ClipboardContent content = new ClipboardContent();

    /*
     * We have to add some content, otherwise drag over will not be called.
     */
    content.putString("dummy"); //$NON-NLS-1$
    db.setContent(content);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:15,代碼來源:AutoScrollPane.java

示例3: startDrag

import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void startDrag(MouseEvent evt) {
    EventTarget target = evt.getTarget();
    if (!isOnEntry(target)) {
        return;
    }
    Dragboard db = startDragAndDrop(TransferMode.MOVE);
    ClipboardContent content = new ClipboardContent();

    /*
     * We have to add some content, otherwise drag over will not be called.
     */
    content.putString("dummy"); //$NON-NLS-1$
    db.setContent(content);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:15,代碼來源:DayViewScrollPane.java

示例4: initDragModeAndHandle

import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
private void initDragModeAndHandle(MouseEvent evt) {
    dragMode = null;
    handle = null;

    if (!(evt.getTarget() instanceof EntryViewBase)) {
        return;
    }

    dayEntryView = (DayEntryView) evt.getTarget();

    entry = dayEntryView.getEntry();
    Calendar calendar = entry.getCalendar();
    if (calendar.isReadOnly()) {
        return;
    }

    double y = evt.getY() - dayEntryView.getBoundsInParent().getMinY();

    LOGGER.finer("y-coordinate inside entry view: " + y);

    if (y > dayEntryView.getHeight() - 5) {
        if (dayView.getEntryEditPolicy().call(new DateControl.EntryEditParameter(dayView, entry, DateControl.EditOperation.CHANGE_END))) {
            dragMode = DraggedEntry.DragMode.END_TIME;
            handle = Handle.BOTTOM;
        }
    } else if (y < 5) {
        if (dayView.getEntryEditPolicy().call(new DateControl.EntryEditParameter(dayView, entry, DateControl.EditOperation.CHANGE_START))) {
            dragMode = DraggedEntry.DragMode.START_TIME;
            handle = Handle.TOP;
        }
    } else {
        if (dayView.getEntryEditPolicy().call(new DateControl.EntryEditParameter(dayView, entry, DateControl.EditOperation.MOVE))) {
            dragMode = DraggedEntry.DragMode.START_AND_END_TIME;
            handle = Handle.CENTER;
        }
    }
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:38,代碼來源:DayViewEditController.java

示例5: processMouseClick

import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
/**
 * Handle a click to a tab.
 */
private void processMouseClick(@NotNull final MouseEvent event) {
    final EventTarget target = event.getTarget();
    if (!(target instanceof Node)) return;

    final Node node = (Node) target;

    if (!(node instanceof Text) || node.getStyleClass().contains("tab-container")) {
        return;
    }

    final Parent label = node.getParent();

    if (!(label instanceof Label)) {
        return;
    }

    final Parent tabContainer = label.getParent();

    if (!tabContainer.getStyleClass().contains("tab-container")) {
        return;
    }

    if (isChangingTab()) {
        setChangingTab(false);
        return;
    }

    processExpandOrCollapse();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:33,代碼來源:TabToolComponent.java

示例6: mousePressed

import javafx.scene.input.MouseEvent; //導入方法依賴的package包/類
@Override protected void mousePressed(MouseEvent me) {
    Node target = (Node) me.getTarget();
    if (onCloseButton(target)) {
        recorder.recordSelect(this, getTextForTab((TabPane) node, getTab(target)) + "::close");
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:7,代碼來源:RFXTabPane.java


注:本文中的javafx.scene.input.MouseEvent.getTarget方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。