In Storm sometimes click event in invoked by clicking outside of a focusable field.
To solve this just add the following code to the MainScreen or a Manager.
protected boolean touchEvent(TouchEvent message) { int event = message.getEvent(); if (event == TouchEvent.CLICK || event == TouchEvent.UNCLICK) { // Ignore clcik events that happen outside any fields if (getFieldAtLocation(message.getX(1), message.getY(1)) == -1) return true; // kill the event } return super.touchEvent(message); } // The regular getFieldAtLocation returns wrong values //in open spaces in complex managers, so we override it public int getFieldAtLocation(int x, int y) { XYRect rect = new XYRect(); int index = getFieldCount() -1; while (index >= 0) { getField(index).getExtent(rect); if (rect.contains(x, y)) break; --index; } return index; }
|
No comments:
Post a Comment