Menu

#62 [JME3] Enable/disable consuming of mouse events by Nifty

closed
void256
General (44)
5
2014-08-17
2011-09-11
void256
No

Currently Nifty consumes mouse button events (via the InputSystemJme.java) if they occur over a Nifty Element. This is preferable behaviour in most situations. It causes trouble in the following:

  1. Start dragging (to navigate over a map)
  2. Drag until the mouse is over an element
  3. Release the mouse button
  4. As the button is consumed by Nifty the other event listener never receives the mouse-up event and therefore continues the dragging behaviour

Simply adding a RawInputListener to handle the drag is not enough, as it might consume events before they reach the Nifty listener in other use-cases.

A simple fix could be to add a consumeEvents boolean to the InputSystemJme that is checked to see if an event should be consumed or not.

Discussion

  • void256

    void256 - 2011-09-11

    There probably should be two booleans to enable/disable mouse and keyboard event handling individually.

     
  • Ace An

    Ace An - 2011-09-11

    I have a question
    will those booleans enable/disable mouse and keyboard handling of every elements or of each individual element?

     
  • void256

    void256 - 2011-09-18

    @xieu90:
    The plan is to have a single boolean to completely disable/enable the processing of mouse and keyboard events.

    Is anything else required?

     
  • Ace An

    Ace An - 2011-09-18

    Hi Void,
    http://download968.mediafire.com/qnv5hnl3wayg/bkxztbcd8n78zpd/mygame11.jar
    (Option--> Control)
    when you press up arrow then you will see it goes up then down (up because of control of button-I think, and down because of me, I made it go to next element )

    at the end I have to use mouse to press on save.

    So if your boolean disable both mouse and keyboard events, then it will get rid of up and down problem, but then I wont be able to press save or reset.

    After disable the processing of mouse and keyboard events, can we still check if the mouse hovers on any element ? If yes I can manually reenable the boolean and for my case it would be enough.
    I dont know if a single boolean for both mouse and keyboard is enough, may be we should have 2, one for mouse and one for keyboard ?
    In summary I dont know if anything else is required. We will see after the boolean and the nightly build from jme3 which has that boolean come out.

     
  • void256

    void256 - 2012-09-08

    fixed in git -> https://github.com/void256/nifty-gui/commit/1d359d7122d3448a30c61c81bb00fdfc593b2636

    62 [JME3] Enable/disable consuming of mouse events by Nifty (sf.net)

    Use nifty.setIgnoreMouseEvents(true) to completely disable mouse event
    processing in Nifty . The NiftyInputConsumer.processMouseEvent() will
    always return false in that case.

    Use nifty.setIgnoreKeyboardEvents(true) to completely disable mouse
    event processing in Nifty. The NiftyInputConsumer.processKeyboardEvent()
    will always return false in that case.

    • status: open --> closed
    • milestone: --> Next_Release_(example)
     
MongoDB Logo MongoDB