private final GdxRenderer renderer = new GdxRenderer();\r
private final GUI gui;\r
\r
+ private boolean mouseDown, ignoreMouse, lastPressConsumed;\r
+\r
/**\r
* Creates a new TWL instance with the specified theme file. The specified widget is added to the root pane.\r
*/\r
}\r
\r
public boolean keyTyped (char character) {\r
- boolean handled = gui.handleKey(0, character, true);\r
- return gui.handleKey(0, character, false) || handled;\r
+ return gui.handleKey(0, character, true);\r
}\r
\r
public boolean touchDown (int x, int y, int pointer) {\r
- return gui.handleMouse(x, y, pointer, true);\r
+ if (!mouseDown) lastPressConsumed = false; // Only the first button down counts.\r
+ mouseDown = true;\r
+ if (ignoreMouse) return false;\r
+ boolean handled = gui.handleMouse(x, y, pointer, true);\r
+ if (handled) lastPressConsumed = true;\r
+ return handled;\r
}\r
\r
public boolean touchUp (int x, int y, int pointer) {\r
+ mouseDown = false;\r
+ if (ignoreMouse) {\r
+ ignoreMouse = false;\r
+ return false;\r
+ }\r
boolean handled = gui.handleMouse(x, y, pointer, false);\r
- gui.handleMouse(-9999, -9999, -1, true);\r
+ gui.handleMouse(-9999, -9999, -1, false);\r
return handled;\r
}\r
\r
public boolean touchDragged (int x, int y, int pointer) {\r
- boolean handled = gui.handleMouse(x, y, -1, true);\r
- System.out.println(handled);\r
- return handled;\r
+ if (mouseDown && !lastPressConsumed) {\r
+ ignoreMouse = true;\r
+ gui.clearMouseState();\r
+ return false;\r
+ }\r
+ return gui.handleMouse(x, y, -1, true);\r
}\r
\r
public void dispose () {\r
return Event.KEY_SPACE;\r
case Keys.KEYCODE_TAB:\r
return Event.KEY_TAB;\r
- default:\r
- return Event.KEY_NONE;\r
}\r
+ return Event.KEY_NONE;\r
}\r
\r
/**\r
* Returns a URL to a theme file, which can be used with\r
* {@link ThemeManager#createThemeManager(URL, de.matthiasmann.twl.renderer.Renderer) ThemeManager} to create a theme for\r
- * {@link GUI#applyTheme(ThemeManager)}. This is only needed if not using the TWL class make use of TWL.\r
+ * {@link GUI#applyTheme(ThemeManager)}. This is only needed if not using the {@link TWL} class to make use of TWL.\r
*/\r
static public URL getThemeURL (String themeFile, final FileType fileType) throws MalformedURLException {\r
File file = new File(themeFile);\r