Hi all. I have been working with tonegod gui for over a week now and I must say it is awesome =D . Once I got the hang of it I started to really love it .
Okay now for the problem. The problem that I am getting is that the setIgnoreMouse(true) is not working in android. It was working before I did the latest update which was yesterday.
I first made a button and later made a label. I set some text to the label. I then called Label.setIgnoreMouse(true) and added the label to the button. The reason I did not use the button text is because I wanted to position the text some where around the button. This was working fine until I updated tonegod gui. After the update the setIgnoreMouse(true) was not working in the android. I tested this three ways.
- Made a button and used its internal text. Works fine.
- Made a button and added label which ignore mouse. Didn’t work.
- Made a bigger button and added label which ignore mouse. Only worked at places where there were no text.
Here is the test case:
[java]
package mygame;
import com.jme3.app.SimpleApplication;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.input.event.MouseMotionEvent;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f;
import com.jme3.renderer.RenderManager;
import tonegod.gui.controls.buttons.Button;
import tonegod.gui.controls.text.Label;
import tonegod.gui.controls.windows.Panel;
import tonegod.gui.core.Screen;
import tonegod.gui.effects.Effect;
/**
-
test
-
@author Kamran Wali
*/
public class Main extends SimpleApplication {private Screen screen;
private Panel mainPanel;
Label button2Text, button3Text;boolean toggle = false;
public static void main(String[] args) {
Main app = new Main();
app.start();
}@Override
public void simpleInitApp() {
mouseInput.setCursorVisible(true);
flyCam.setEnabled(false);screen = new Screen(this, "tonegod/gui/style/atlasdef/style_map.gui.xml"); screen.setUseTextureAtlas(true,"tonegod/gui/style/atlasdef/atlas.png"); screen.setUseMultiTouch(true); guiNode.addControl(screen); screen.setUseKeyboardIcons(true); screen.setUse3DSceneSupport(true); //<==Button 1==> Button button1 = new Button(screen, "button1", new Vector2f(settings.getWidth() * .5f, settings.getHeight() * .5f), /*Pos*/ new Vector2f(settings.getWidth() * .1f, settings.getHeight() * .07f) /*Dim*/ ) { @Override public void onButtonMouseLeftDown(MouseButtonEvent arg0, boolean arg1) { setFontColor(ColorRGBA.Red); } @Override public void onButtonMouseRightDown(MouseButtonEvent arg0, boolean arg1) { } @Override public void onButtonMouseLeftUp(MouseButtonEvent arg0, boolean arg1) { } @Override public void onButtonMouseRightUp(MouseButtonEvent arg0, boolean arg1) { } @Override public void onButtonFocus(MouseMotionEvent arg0) { } @Override public void onButtonLostFocus(MouseMotionEvent arg0) { } }; button1.setIsResizable(false); button1.setText("Button1"); button1.setFontSize((button1.getFont().getCharSet().getRenderedSize()/button1.getFont().getCharSet().getRenderedSize()) * (settings.getWidth() * .03f)); button1.removeEffect(Effect.EffectEvent.Hover); button1.removeEffect(Effect.EffectEvent.Press); //<==Button 2==> Button button2 = new Button(screen, "button2", new Vector2f(settings.getWidth() * .3f, settings.getHeight() * .5f), /*Pos*/ new Vector2f(settings.getWidth() * .1f, settings.getHeight() * .07f) /*Dim*/ ) { @Override public void onButtonMouseLeftDown(MouseButtonEvent arg0, boolean arg1) { toggle = !toggle; if(toggle){ button2Text.setFontColor(ColorRGBA.Red); }else{ button2Text.setFontColor(ColorRGBA.White); } } @Override public void onButtonMouseRightDown(MouseButtonEvent arg0, boolean arg1) { } @Override public void onButtonMouseLeftUp(MouseButtonEvent arg0, boolean arg1) { } @Override public void onButtonMouseRightUp(MouseButtonEvent arg0, boolean arg1) { } @Override public void onButtonFocus(MouseMotionEvent arg0) { } @Override public void onButtonLostFocus(MouseMotionEvent arg0) { } }; button2.setIsResizable(false); button2.removeEffect(Effect.EffectEvent.Hover); button2.removeEffect(Effect.EffectEvent.Press); button2Text = new Label(screen, "button2Text", new Vector2f(settings.getWidth() * .005f, settings.getHeight() * -.025f), new Vector2f(settings.getWidth() * .1f, settings.getHeight() * .1f)); button2Text.setText("Button2"); button2Text.setFontSize((button2Text.getFont().getCharSet().getRenderedSize()/button2Text.getFont().getCharSet().getRenderedSize()) * (settings.getWidth() * .03f)); button2Text.setIgnoreMouse(true); //<-- Not Working button2Text.setIgnoreMouseButtons(true); //<-- Not Working button2.addChild(button2Text);
// button2Text.setIgnoreMouse(true); //<-- Not Working
// button2Text.setIgnoreMouseButtons(true); //<-- Not Working
//<==Button 3==>
Button button3 = new Button(screen,
"button3",
new Vector2f(settings.getWidth() * .1f, settings.getHeight() * .5f), /*Pos*/
new Vector2f(settings.getWidth() * .1f, settings.getHeight() * .1f) /*Dim*/
) {
@Override
public void onButtonMouseLeftDown(MouseButtonEvent arg0, boolean arg1) {
toggle = !toggle;
if(toggle){
button3Text.setFontColor(ColorRGBA.Red);
}else{
button3Text.setFontColor(ColorRGBA.White);
}
}
@Override
public void onButtonMouseRightDown(MouseButtonEvent arg0, boolean arg1) {
}
@Override
public void onButtonMouseLeftUp(MouseButtonEvent arg0, boolean arg1) {
}
@Override
public void onButtonMouseRightUp(MouseButtonEvent arg0, boolean arg1) {
}
@Override
public void onButtonFocus(MouseMotionEvent arg0) {
}
@Override
public void onButtonLostFocus(MouseMotionEvent arg0) {
}
};
button3.setIsResizable(false);
button3.removeEffect(Effect.EffectEvent.Hover);
button3.removeEffect(Effect.EffectEvent.Press);
button3Text = new Label(screen,
"button3Text",
new Vector2f(settings.getWidth() * .005f, settings.getHeight() * -.03f),
new Vector2f(settings.getWidth() * .1f, settings.getHeight() * .1f));
button3Text.setText("Button3");
button3Text.setFontSize((button3Text.getFont().getCharSet().getRenderedSize()/button3Text.getFont().getCharSet().getRenderedSize()) * (settings.getWidth() * .03f));
button3Text.setIgnoreMouse(true); //<-- Not Working
button3Text.setIgnoreMouseButtons(true); //<-- Not Working
button3.addChild(button3Text);
// button2Text.setIgnoreMouse(true); //<-- Not Working
// button2Text.setIgnoreMouseButtons(true); //<-- Not Working
mainPanel = new Panel(screen,
"MainPanel",
Vector2f.ZERO,
new Vector2f(settings.getWidth() * 1f, settings.getHeight() * 1f));
mainPanel.setIsMovable(false);
mainPanel.setIsResizable(false);
mainPanel.setIgnoreMouseButtons(true);
mainPanel.addChild(button1);
mainPanel.addChild(button2);
mainPanel.addChild(button3);
screen.addElement(mainPanel);
}
@Override
public void simpleUpdate(float tpf) {
//TODO: add update code
}
@Override
public void simpleRender(RenderManager rm) {
//TODO: add render code
}
}
[/java]
When the buttons are clicked their texts will turn red and when you click again it will turn white. In button2 it is very difficult to press it since the label covers most of it. When the lower parts of the Button3 is pressed only then it works. Button1 works fine, when pressed it turns red and when released it turns white again.
I Hope I could explain it properly and thank you.
K Out!