Error with nifty and awt

The mouse event do work. When the touch event happens, there was a post to nifty. The problem was that the x and y values being forwarded to nifty were only updated during a mouse move which doesn’t exist on a touch screen. This caused the x and y to always be 0,0 when nifty saw them.

Is there any plans on updating the nifty gui code to incorporate this fix?

I can confirm that this is fixing the issue.

I committed the fix, it’s in last SVN.

When would such a change show up in the platform? I assume since it’s in Beta, the overnight build process will not be pushed out automatically unless the nightly version is being used?

If you are using nightly, tomorrow.

If you are using stable release you’ll have to wait for the next stable release, which is not planned yet.

I’v downloaded through the svn for 1-2 days ago and I’m getting this error when trying to go to a screen.

Is the svn the latest stable release or is it the latest release?

Okej, I’m not getting exacly the same. I get:

Could not find class 'de.lessvoid.nifty.ClipboardAWT', referenced from method de.lessvoid.nifty.Nifty.initializeClipboard

I'm using android 2.3.3 on htc desire z.

@nehon

I discovered a couple of issues with the code I submitted before to get the x and y communicated to nifty for touch events:



Incorrect Parameters being passed to processMouseEvent

In InputSystemJme, the onTouchEventQueued routine is sending incorrect parameters to processMouseEvent



Double posting of touch events to nifty due to mouseEventsEnabled=true in main activity

When users have the AndroidHarness variable mouseEventsEnabled = true (default setting in AndroidHarness), InputSystemJme is actually sending both the Touch Event and the Mouse Button Event to Nifty. In my case, the first event to register fired off my nifty code to change to a new menu display and then the second event would get applied to the new screen causing the screen to switch yet again to a third screen. When I set mouseEventsEnabled = false in my MainActivity, the issue went away. I believe to fix this, InputSystemJme needs to have visibility to whether or not the TouchInput is set to simulate mouse events or not (ie. if it is, then don’t send the touch events to nifty since the mouse button event is coming).



Anyway, below is what I believe fixes both issues. There have been a few posts lately about click events with Android and Nifty. I’m not sure if the fixes below will take care of them as well, but it might.



Can you review the code below and apply the fix if you think it is ok? They are based on the latest engine as of today. Maybe you can check in these changes when you put in the soft keyboard changes.



Thanks,



TouchInput

[java]

This patch file was generated by NetBeans IDE

Following Index: paths are relative to: D:UserspotterecDocumentsjMonkeyProjectsjME3srccorecomjme3input

This patch can be applied using context Tools: Patch action on respective folder.

It uses platform neutral UTF-8 encoding and n newlines.

Above lines and this line are ignored by the patching process.

Index: TouchInput.java

— TouchInput.java Base (BASE)

+++ TouchInput.java Locally Modified (Based On LOCAL)

@@ -75,6 +75,12 @@

public void setSimulateMouse(boolean simulate);



/**

  • * Get if mouse events are generated<br />
    
  • *<br />
    
  • */<br />
    
  • public boolean getSimulateMouse();

    +
  • /**

    No newline at end of file
  • Set if keyboard events should be generated

    *
  • @param simulate if keyboard events should be generated



    [/java]



    AndroidInput

    [java]

This patch file was generated by NetBeans IDE

Following Index: paths are relative to: D:UserspotterecDocumentsjMonkeyProjectsjME3srcandroidcomjme3inputandroid

This patch can be applied using context Tools: Patch action on respective folder.

It uses platform neutral UTF-8 encoding and n newlines.

Above lines and this line are ignored by the patching process.

Index: AndroidInput.java

— AndroidInput.java Base (BASE)

+++ AndroidInput.java Locally Modified (Based On LOCAL)

@@ -578,6 +578,10 @@

public void setSimulateMouse(boolean simulate) {

mouseEventsEnabled = simulate;

}

  • @Override
  • public boolean getSimulateMouse() {
  •    return mouseEventsEnabled;<br />
    
  • }



    @Override

    public void setSimulateKeyboard(boolean simulate) {



    [/java]



    InputManager

    [java]

This patch file was generated by NetBeans IDE

Following Index: paths are relative to: D:UserspotterecDocumentsjMonkeyProjectsjME3srccorecomjme3input

This patch can be applied using context Tools: Patch action on respective folder.

It uses platform neutral UTF-8 encoding and n newlines.

Above lines and this line are ignored by the patching process.

Index: InputManager.java

— InputManager.java Base (BASE)

+++ InputManager.java Locally Modified (Based On LOCAL)

@@ -731,6 +731,17 @@

touch.setSimulateMouse(value);

}

}

  • /**
  • * Returns state of simulation of mouse events. Used for touchscreen input only.<br />
    
  • *<br />
    
  • */<br />
    
  • public boolean getSimulateMouse() {
  •    if (touch != null) {<br />
    
  •        return touch.getSimulateMouse();<br />
    
  •    } else {<br />
    
  •        return false;<br />
    
  •    }<br />
    
  • }



    /**
  • Enable simulation of keyboard events. Used for touchscreen input only.



    [/java]



    InputSystemJme

    [java]

This patch file was generated by NetBeans IDE

Following Index: paths are relative to: D:UserspotterecDocumentsjMonkeyProjectsjME3srcniftyguicomjme3niftygui

This patch can be applied using context Tools: Patch action on respective folder.

It uses platform neutral UTF-8 encoding and n newlines.

Above lines and this line are ignored by the patching process.

Index: InputSystemJme.java

— InputSystemJme.java Base (BASE)

+++ InputSystemJme.java Locally Modified (Based On LOCAL)

@@ -95,9 +95,10 @@

x = (int) evt.getX();

y = (int) (height - evt.getY());


  •    if (!inputManager.getSimulateMouse()) {<br />
    

switch (evt.getType()) {

case DOWN:

  •           consumed = nic.processMouseEvent(x, y, 0, 0, false);<br />
    
  •               consumed = nic.processMouseEvent(x, y, 0, 0, true);<br />
    

isDragging = true;

niftyOwnsDragging = consumed;

if (consumed){

@@ -108,7 +109,7 @@



case UP:

if (niftyOwnsDragging){

  •               consumed = nic.processMouseEvent(x, y, 0, buttonIndex, pressed);<br />
    
  •                   consumed = nic.processMouseEvent(x, y, 0, 0, false);<br />
    

if (consumed){

evt.setConsumed();

}

@@ -119,6 +120,7 @@

break;

}

}

  • }



    private void onMouseMotionEventQueued(MouseMotionEvent evt, NiftyInputConsumer nic) {

    x = evt.getX();



    [/java]
1 Like

@iwgeric good, i"ll integrate your fixes!

Thanks a lot.

committed in last SVN