Non-interactive, but enabled, buttons? O_o

Ok, it seems I need help with a trivial thing. :confused:

I’m almost done with one of the last GUI transition thing but for some reason, the buttons I put there aren’t interactive although they are displayed and enabled. Hovering, clicking or anything doesn’t do anything…

It’s very simple. An Element called frame on which I attach 2 buttons. frame is itself attached to a panel.

What should I do to find the problem… Not sure how to go at it.

[java]
// Class constructor where I make other controls…
Element frame5 = new Element(screen, null, new Vector2f(1017f, 0f), size, resize, null);
harvesterBut = new Button(screen, null, new Vector2f(24f, 55f), new Vector2f(138f, 22f)) {
// buttony stuff
}
harvesterBut.setText(“Launch Harvester”);
// two more buttons after that…

    frame5.addChild(harvesterBut);
    frame5.addChild(harvestClose);
    frame5.addChild(harvestNode);

    mapPanel.addChild(frame5);

[/java]

I’ve tried changing the base Panel to Element, using a texture instead of null, removed frame5 and put the button on the base panel… all with the same result. Buttons ARE on the screen but not interactive.

Halp?

Hm… I don’t see anything related to handling the click event - is that “buttony stuff”?
If the event handling is via override, it might also be a typo in the overriding function’s name. (Unless an @Override annotation is present, of course.)

I just didn’t want to paste the whole thing as it’s just run-of-the-mill stuff. Here it is.

[java]
harvesterBut = new Button(screen, null, new Vector2f(24f, 55f), new Vector2f(138f, 22f)) {

        @Override
        public void onButtonMouseLeftDown(MouseButtonEvent evt, boolean toggled) {
        }

        @Override
        public void onButtonMouseRightDown(MouseButtonEvent evt, boolean toggled) {
        }

        @Override
        public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
        }

        @Override
        public void onButtonMouseRightUp(MouseButtonEvent evt, boolean toggled) {
            asm.getState(MapView.class).launchHarvester();
        }

        @Override
        public void onButtonFocus(MouseMotionEvent evt) {
        }

        @Override
        public void onButtonLostFocus(MouseMotionEvent evt) {
        }
    };

[/java]

Just can’t put my finger on the cause of this. I’ve done other parts of the GUI in the same way without a problem. Must be a stupid thing. Or maybe not… I don’t know. :confused:

Just to exclude any stupidity: You did verify that onButtonMouseRightUp is never called?

I remember one issue that I had with Nifty in windowed mode (i.e. this applies only if you’re not starting in fullscreen mode).
Nifty would draw the buttons at an offset (specifically, too far to the top and a bit to the left). The mouse position, however, would be processed at the correct position, so I had to move the mouse down to hit the buttons. This would autocorrect as soon as I’d resize the window.
I guess Nifty is picking up the coordinates before AWT determines the size of window decorations, and gets that right only after a resize.
I did a bit of debugging and think that the LWJGL canvas code was involved, too; maybe Toneguigui is affected in the same way.

I tried that already and nope. Not working. There’s no highlight when hovering or click processed at or around the button’s position.

I’m trying to get the same behavior in a new project… I’ll repost with results eventually.

K, got it to work in a different project, so there’s gotta be some kind of weird thing going on… I’ll continue digging…

Oh, FYI @t0neg0d it’s mandatory to have a UID with controls that have an effect! I just got a crash while testing the buttons while they had null as UID.

Here’s the stack trace.

[java]
Apr 11, 2013 5:14:09 PM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at tonegod.gui.effects.EffectManager.applyEffect(EffectManager.java:41)
at tonegod.gui.controls.buttons.Button.runLoseFocusEffect(Button.java:415)
at tonegod.gui.controls.buttons.Button.onLoseFocus(Button.java:569)
at tonegod.gui.core.Screen.onMouseMotionEvent(Screen.java:489)
at com.jme3.input.InputManager.processQueue(InputManager.java:801)
at com.jme3.input.InputManager.update(InputManager.java:881)
at com.jme3.app.Application.update(Application.java:604)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:231)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)
at java.lang.Thread.run(Thread.java:722)
[/java]

Forgot to post that I found the main reason why it was behaving that way.

It’s the only thing I hate in the GUI exactly because it brings that kind of problem: I didn’t attach the whole thing to the screen. By using screen in the control constructors, everything will be displayed on the screen, but interaction is not possible. Like the above.

Why I forgot it, I don’t know. This isn’t the first time it happens and I remember swearing to myself that I would know next time… Yeah. That didn’t quite work now did it? -.-

Problem seems to not be fixed entirely, but at least hovering works now. Partial working is better than nothing. Anyway…

Also noted there were many, many problems when I decided to not use UIDs, or actually using null as UID.

@t0neg0d

A little something you might want to put… Just saying.

[java]

This patch file was generated by NetBeans IDE

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

— Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -28,10 +28,12 @@
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import tonegod.gui.controls.extras.DragElement;
import tonegod.gui.controls.form.Form;
+import tonegod.gui.core.utils.UIDUtil;
import tonegod.gui.effects.Effect;

/**
@@ -186,7 +188,11 @@
public Element(Screen screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String texturePath) {
this.app = screen.getApplication();
this.screen = screen;

  •            if (UID == null) {
    
  •                this.UID = UIDUtil.getUID();
    
  •            } else {
      this.UID = UID;
    
  •            }
      this.position.set(position);
      this.dimensions.set(dimensions);
    
    // this.minDimensions = dimensions.clone();
    [/java]
1 Like

Man… I am so sorry. I missed this post completely (seems to happen a lot over the last week)

Not to be an excuse monger… but here is my list:

  1. Father is dying
  2. Husbands company is closing and we may be moving across country soon.
  3. 1 and 2 are probably enough.

Now for things to try…

I have found that (in some cases) when you can see an element in the correct order but it is not reacting to input, whatever mechanism JME uses for sorting for ray casting isn’t seeing nodes in the proper order.

The fix I have used, is detaching the screen level parent element and reattaching it. For some reason this seems to update the order in a way that ray casting returns the proper results.

I could be WAAAAAAY off here, but it’s worth a try.

@madjack

Yeah… UID’s are needed as elements are stored in hashmaps that use the UID as a key. Passing in null won’t work, however… your patch will fix that problem… soooo… thank you!!

@t0neg0d said: Man... I am so sorry. I missed this post completely (seems to happen a lot over the last week)

Chis, you don’t have to justify anything. Not to me, not to anyone else.

I will be content to bring stuff to your attention and hope it gets fixed, when applicable, when it gets fixed. Do I think you’re juggling too many knifes at the same time? Possibly… :stuck_out_tongue: But it’s not my business to tell you what to do.

Anyway… I’ll try that solution but I’m not holding my breath. :wink:

The problem has evolved a bit. Everything that was wrong around has been fixed. At least i hope so. The only weird crap happening is the click not being “processed”. Hovering effect works, but clicks are not…

I’ll find the problem eventually. I hope before my brain gets fried. :stuck_out_tongue:

@madjack said: I just didn't want to paste the whole thing as it's just run-of-the-mill stuff. Here it is.

[java]
harvesterBut = new Button(screen, null, new Vector2f(24f, 55f), new Vector2f(138f, 22f)) {

        @Override
        public void onButtonMouseLeftDown(MouseButtonEvent evt, boolean toggled) {
        }

        @Override
        public void onButtonMouseRightDown(MouseButtonEvent evt, boolean toggled) {
        }

        @Override
        public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
        }

        @Override
        public void onButtonMouseRightUp(MouseButtonEvent evt, boolean toggled) {
            asm.getState(MapView.class).launchHarvester();
        }

        @Override
        public void onButtonFocus(MouseMotionEvent evt) {
        }

        @Override
        public void onButtonLostFocus(MouseMotionEvent evt) {
        }
    };

[/java]

Just can’t put my finger on the cause of this. I’ve done other parts of the GUI in the same way without a problem. Must be a stupid thing. Or maybe not… I don’t know. :confused:

Y u no use ButtonAdapter?

@t0neg0d said: Y u no use ButtonAdapter?

Because I’m a narrow-minded dumbass?
I just saw BUTTON and didn’t look farther?

Take your pick. :stuck_out_tongue:

@madjack
I applied the above patch and committed it.

Time to go through other posts and get those taken care of too. :stuck_out_tongue:

@madjack said: Because I'm a narrow-minded dumbass? I just saw BUTTON and didn't look farther?

Take your pick. :stuck_out_tongue:

To save myself typing… I start with button, change it to ButtonAdapter and then remove the unused event methods. Condenses code for sure

@madjack
Ack… sorry for all the random posts… With the patch you gave above, this will catch-all and I won’t need to worry about the the error you encountered above, correct?

@t0neg0d said: To save myself typing... I start with button, change it to ButtonAdapter and then remove the unused event methods. Condenses code for sure

Yes. I just did that to ALL THE BUTTONS!

Oh and btw, the answer is: All the above. :stuck_out_tongue:

@t0neg0d said: @madjack Ack... sorry for all the random posts... With the patch you gave above, this will catch-all and I won't need to worry about the the error you encountered above, correct?

Correct. If any other dumbass like me forces an UID to null this would catch it.

1 Like
@t0neg0d said: The fix I have used, is detaching the screen level parent element and reattaching it. For some reason this seems to update the order in a way that ray casting returns the proper results.

I could be WAAAAAAY off here, but it’s worth a try.

No joy.

Actually this brought another problem. The panel, when reattached, wasn’t at the same position it was before being removed. It doesn’t really matter though since clicking didn’t do anything. I’ve added some System.out.println() in there just to be certain.

I need to be slapped. Really hard.

On right mouse button? No, I think not. On the LEFT MOUSE BUTTON YOU DAMN IDIOT.

sigh

It works as it should now.

1 Like