Posted August 17, 201411 yr I'm making a book for my mod. At first when you open the book you are presented with an index, after that another index with a more specific list of items or blocks. The problem is that when I click in one of the menus, it instantly clicks on the second menu that is on the same coordinate. Here's a gfy explaining my interface and my problem Basicly, what I want is index > subindex > item/block entry And its going index >item/block entry If my code for my GUI is needed, here it is:GitHub // Code is messy, just started getting into Java http://i.imgur.com/J2keQOC.png[/img]http://i.imgur.com/YHnvIfh.png[/img]
August 17, 201411 yr Simply by override the GuiScreen#mouseClicked(int x, int y, int mouseId) like this: @Override /** @param x = relative mouse position x @param y = relative mouse position y @param mouseId = mouse button being pressed */ protected void mouseClicked(int x, int y, int mouseId) { super.mouseClicked(x, y, mouseId); this.initGui(); } Do not call the initGui method during the actionPerformed method because when the mouse is pressed on top of a GuiButton it goes into a loop. When you draw a new button on the same location and the mouse is not released, it continues the loop (the code gets executed immediately so you can never time it when to release your mouse . So when the mouseClicked is done (super call), you re initialize your gui elements. There is no double clicking involved, just fast execution. ;] Note, when writing in Java you should rename the button classes to start with a capital letter. http://journals.ecs.soton.ac.uk/java/tutorial/java/javaOO/classdecl.html
August 17, 201411 yr Author Worked like a charm! Thank you very much sir! Also thanks for the tip on naming classes! Was used to naming with first lower and then upper case, dont know why http://i.imgur.com/J2keQOC.png[/img]http://i.imgur.com/YHnvIfh.png[/img]
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.