/** Adds a close button. */ private void addCloseButton() { log.debug("Entering addCloseButton()"); // $NON-NLS-1$ // Create close button MTSvgButton closeButton = new MTSvgButton(this.mtApplication, BUTTON_CLOSE_IMG_PATH); // Remove all default gesture listeners ToolsEventHandling.removeScaleProcessorsAndListeners(closeButton); ToolsEventHandling.removeDragProcessorsAndListeners(closeButton); ToolsEventHandling.removeRotateProcessorsAndListeners(closeButton); // Set width float parentWidth = this.getWidthXY(TransformSpace.GLOBAL); closeButton.setWidthXYGlobal(parentWidth * BUTTON_CLOSE_WIDTH_SCALE_TO_OVERLAY_PERCENT); this.addChild(closeButton); // Set picking behaviour closeButton.setBoundsPickingBehaviour(AbstractShape.BOUNDS_ONLY_CHECK); // Add tap gesture listener addTapGestureListener(closeButton); // Position at touch point north east closeButton.setPositionGlobal(this.getTouchPointNorthEast()); // Reposition closeButton.translate( new Vector3D( -(closeButton.getWidthXYGlobal() * BUTTON_CLOSE_X_OFFSET_FROM_TPNE_PERCENT), closeButton.getHeightXYGlobal() * BUTTON_CLOSE_Y_OFFSET_FROM_TPNE_PERCENT, 0)); // Set bounding behaviour closeButton.setBoundsPickingBehaviour(AbstractShape.BOUNDS_ONLY_CHECK); // Add tap gesture listener addTapGestureListener(closeButton); log.debug("Leaving addCloseButton()"); // $NON-NLS-1$ }
/** * Adds a new tap gesture listener to a svg button for the close action. * * @param svgButton the SVG Button instance */ private void addTapGestureListener(MTSvgButton svgButton) { log.debug( "Entering addTapGestureListener(svgButton=" + svgButton + ")"); // $NON-NLS-1$ //$NON-NLS-2$ svgButton.addGestureListener( TapProcessor.class, new IGestureEventListener() { @Override public boolean processGestureEvent(MTGestureEvent ge) { TapEvent te = (TapEvent) ge; if (te.isTapped()) { log.trace("Close Button has been tapped!"); // $NON-NLS-1$ onCloseButtonTapped(); } return false; } }); log.debug("Leaving addTapGestureListener()"); // $NON-NLS-1$ }