Java Code Examples for javafx.scene.control.ButtonBase#isArmed()
The following examples show how to use
javafx.scene.control.ButtonBase#isArmed() .
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: SlideCheckBoxBehavior.java From JFX8CustomControls with Apache License 2.0 | 6 votes |
/** * Invoked when a mouse press has occurred over the button. In addition to * potentially arming the Button, this will transfer focus to the button */ @Override public void mousePressed(MouseEvent e) { final ButtonBase button = getControl(); super.mousePressed(e); // if the button is not already focused, then request the focus if (! button.isFocused() && button.isFocusTraversable()) { button.requestFocus(); } // arm the button if it is a valid mouse event // Note there appears to be a bug where if I press and hold and release // then there is a clickCount of 0 on the release, whereas a quick click // has a release clickCount of 1. So here I'll check clickCount <= 1, // though it should really be == 1 I think. boolean valid = (e.getButton() == MouseButton.PRIMARY && ! (e.isMiddleButtonDown() || e.isSecondaryButtonDown() || e.isShiftDown() || e.isControlDown() || e.isAltDown() || e.isMetaDown())); if (! button.isArmed() && valid) { button.arm(); } }
Example 2
Source File: SlideCheckBoxBehavior.java From JFX8CustomControls with Apache License 2.0 | 5 votes |
/** * This function is invoked when an appropriate keystroke occurs which * causes this button to be armed if it is not already armed by a mouse * press. */ private void keyPressed() { final ButtonBase button = getControl(); if (!button.isPressed() && !button.isArmed()) { keyDown = true; button.arm(); } }
Example 3
Source File: SlideCheckBoxBehavior.java From JFX8CustomControls with Apache License 2.0 | 5 votes |
/** * Invoked when a valid keystroke release occurs which causes the button * to fire if it was armed by a keyPress. */ private void keyReleased() { final ButtonBase button = getControl(); if (keyDown) { keyDown = false; if (button.isArmed()) { button.disarm(); button.fire(); } } }
Example 4
Source File: SlideCheckBoxBehavior.java From JFX8CustomControls with Apache License 2.0 | 5 votes |
/** * Invoked when a mouse release has occurred. We determine whether this * was done in a manner that would fire the button's action. This happens * only if the button was armed by a corresponding mouse press. */ @Override public void mouseReleased(MouseEvent e) { // if armed by a mouse press instead of key press, then fire! final ButtonBase button = getControl(); if (! keyDown && button.isArmed()) { button.fire(); button.disarm(); } }
Example 5
Source File: SlideCheckBoxBehavior.java From JFX8CustomControls with Apache License 2.0 | 5 votes |
/** * Invoked when the mouse exits the Button. If the Button is armed due to * a mouse press, then this function will disarm the button upon the mouse * exiting it. */ @Override public void mouseExited(MouseEvent e) { // Disarm if necessary final ButtonBase button = getControl(); super.mouseExited(e); if (! keyDown && button.isArmed()) { button.disarm(); } }