Java Code Examples for com.jme3.input.event.MouseButtonEvent#setConsumed()

The following examples show how to use com.jme3.input.event.MouseButtonEvent#setConsumed() . 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: Button.java    From Lemur with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void mouseButtonEvent( MouseButtonEvent event, Spatial target, Spatial capture ) {

    // Buttons always consume their click events
    event.setConsumed();

    // Do our own better handling of 'click' now
    //super.mouseButtonEvent(event, target, capture);
    if( !isEnabled() )
        return;                                            

    if( event.isPressed() ) {
        setPressed(event.isPressed());
    } else if( isPressed() ) {
        // Only run the up processing if we were already pressed
        // This also handles the case where we weren't enabled before
        // but are now, etc.
        
        if( target == capture ) {
            // Then we are still over the button and we should run the
            // click
            runClick();
        }
        // If we run the up without checking properly then we
        // potentially get up events with no down event.  This messes
        // up listeners that are (correctly) expecting an up for every
        // down and no ups without downs.
        // So, any time the capture is us then we will run, else not
        if( capture == Button.this ) {
            setPressed(false);
        }
    }
}
 
Example 2
Source File: InputSystemJme.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void onMouseButtonEventQueued(MouseButtonEvent evt, NiftyInputConsumer nic) {
    boolean wasPressed = pressed;
    boolean forwardToNifty = true;
    
    buttonIndex = evt.getButtonIndex();
    pressed = evt.isPressed();
    
    // Mouse button raised. End dragging
    if (wasPressed && !pressed){
        if (!niftyOwnsDragging){
            forwardToNifty = false;
        }
        isDragging = false;
        niftyOwnsDragging = false;
    }

    boolean consumed = false;
    if (forwardToNifty){
        consumed = nic.processMouseEvent(x, y, 0, buttonIndex, pressed);
        if (consumed){
            evt.setConsumed();
        }
    }
    
    // Mouse button pressed. Begin dragging
    if (!wasPressed && pressed){
        isDragging = true;
        niftyOwnsDragging = consumed;
    }
}
 
Example 3
Source File: MouseAppState.java    From Lemur with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected void dispatch( MouseButtonEvent evt ) {
    if( getSession().buttonEvent(evt.getButtonIndex(), evt.getX(), evt.getY(), evt.isPressed()) ) {
        evt.setConsumed();
    }
}