Need to go test this⦠however, a couple of observations:
[java]
dropWindow.setIsResizable(false);
[/java]
and
[java]
public class ItemButton extends ButtonAdapter {
public ItemButton(ElementManager screen, String UID, Vector2f position, String texte) {
super(screen, UID, position);
this.setWidth(190);
this.setHeight(30);
this.setText(texte);
}
@Override
public void onButtonMouseLeftDown(MouseButtonEvent arg0, boolean arg1) {
System.out.println(āouchā);
}
}
[/java]
Will help minimize your code. Even if you originally extend Button⦠ALT+ENTER to implement abstract methods⦠then change it to ButtonAdapter and ditch the methods you donāt need.
And⦠now Iāll go test this and see what the issue is =)
Ok, thank you for your advice.
I do not understand why I have no problem in my little test and why, when I copy past the code in my game it is working fine.
Anyway, really nice GUI .
@toggy said:
Well I have again the problem when I added the name of my item ("Monkey Head") as text for button :(
Havenāt forgotten about this⦠trying to get some stuff wrapped up (fixes for things like the scrollable dropdowns account for text padding and such). I should be able to get to this in just a bit here⦠need to run a few more tests and commit the changes if all goes well⦠then this.
@loopies said:
Try inverting the order of these two lines:
screen.addElement(dropWindow);
dropWindow.addChild(new ItemButton(screen, ābtn1ā³, new Vector2f(5, 50), āMonkey headā));
This solution does work⦠however, you should be able to add this after adding the window to the screen, so I need to figure out why this is happening in this case.
@toggy said:
Well I have again the problem when I added the name of my item ("Monkey Head") as text for button :(
For the time being, Iām going to have to say to go with @loopies solution. Iām not entire sure how to fix this as it is actually the collision results being returned in the improper order (i.e. result.getContactPoint().z should be in order of closest to furthest while iterating through the results and for some reason this is not the case when adding these in this order)
Iāll continue to try and resolve this, but use the suggested fix for now.
@toggy said:
Ok thank you I will do it.
If I still have problem I wll take the source and see if I can do something (Probably not, but I prefer to try ^^)
Please do! Let me know if you are able to find something I have missed. At some point tomorrow Iāll put together the test case and find out if I can repro this using quads + bitmaptext
Yes I can give you my code but it will be a bit hard to read, if you agree I give you only the part with the ādrop windowā in order to be more readable (I am not scary to give the whole code but it is not a reallly proper code actually, I do not like GUI so I do ugly code ^^ ):
Here is my init:
[java] dropWindow = new Window(ConstClient.gc.getScreenUI(), āDrop Windowā, new Vector2f(15, 15),
new Vector2f(200, 300)
);
In fact this way to code is bad I think, and when I copy past I have found an other way to do it, I will initialize all buttons in my init, but set their visible false, and changer their content when I open the drop window. I think it is the good way to do it, I do not know why I do not think like that before ^^"
So do not worry about that bug āfor meā, I will correct it easily, but I understand this bug is not ācoolā for your work.
I want to say with a simple little text like ā#0ā the button was working pretty good, the text is probably the reason. I do not know how your code work, but you could check if the text.getParent() is an instance of button ? So it could reduce the bug.
@author jo
*/
public class HelloGUI extends SimpleApplication {
public class ItemButton extends Button {
public ItemButton(ElementManager screen, String UID, Vector2f position, String texte) {
super(screen, UID, position);
this.setWidth(190);
this.setHeight(30);
this.setText(texte);
}
@Override
public void onButtonFocus(MouseMotionEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void onButtonLostFocus(MouseMotionEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void onButtonMouseLeftDown(MouseButtonEvent arg0, boolean arg1) {
System.out.println("ouch");
}
@Override
public void onButtonMouseLeftUp(MouseButtonEvent arg0, boolean arg1) {
// TODO Auto-generated method stub
}
@Override
public void onButtonMouseRightDown(MouseButtonEvent arg0, boolean arg1) {
// TODO Auto-generated method stub
}
@Override
public void onButtonMouseRightUp(MouseButtonEvent arg0, boolean arg1) {
// TODO Auto-generated method stub
}
}
public static void main(String[] args) {
new HelloGUI().start();
}
@Override
public void simpleInitApp() {
flyCam.setEnabled(false);
this.setDisplayFps(false);
this.setDisplayStatView(false);
Screen screen = new Screen(this);
guiNode.addControl(screen);
Window dropWindow = new Window(screen, "Drop Window", new Vector2f(15, 15),
new Vector2f(200, 300));
dropWindow.setResizeE(false);
dropWindow.setResizeW(false);
dropWindow.setResizeS(false);
dropWindow.setResizeN(false);
//dropWindow.setText(" Items drop");
dropWindow.addChild(new ItemButton(screen, "btn1", new Vector2f(5, 50), "Monkey head"));
screen.addElement(dropWindow);
}
}
[/java]
When the lines arenāt inverted, the button doesnāt react but does when the lines are inverted like here.
I always follow this rule: fill the children before adding them to the parents. So fill your button then add it to the window, fill other window stuff then add them to the window and then add the window to the screen.
@toggy
Happy to report I finally found and fixed this issue.
Please be patient with me getting the update out there, as I have a huge list of things I am changing / updating to try and square away the library solid Beta. Until you gave me this test case, the problem was intermittent, so I had no reliable way of reproducing it to fix it.
BIG thanks for taking the time to do this!
Iāll post a new thread soon discussing all of the updates and changes and when I expect to have them available.