601 views
in GUI Development by
Is it possible to react to a touch event outside of a modal dialog?

1 Answer

0 votes
by

Hello,

by making a GUI component modal, the event dispatching is automatically restricted to this component. Touching outside the component will be ignored. Since with modal component the remaining GUI should be suppressed from being able to handle user inputs, this is a meaningful behavior.

In particular cases, however, it may be necessary to detect touch events when the user tries to touch the screen outside the actually modal component. As effect of such interaction, the appliocation could e.g. dismiss the modal component, etc. How to achieve this?

Option 1: Adjust the size of dialog component to fill the entire screen. It is not necessary to fill the complete component with contents. The component may remain empty (transparent) with the original (smaller) dialog arranged in its center, etc. Put a simple touch handler in the background of the component to catch all touch events. Accordingly, when the user touches outside the area of the original dialog, the touch handler is activated and you can e.g. dismiss the dialog.

Option 2: In your Application class override the method DriveCursorHitting(). This method is invoked every time the user touches the screen. By overriding the method you can add functionality to handle the special case of touch events generated outside the actually modal dialog. The following code demonstrates such adaptation of the DriveCursorHitting() method:

Best regards

Paul Banach

Embedded Wizard Website | Privacy Policy | Imprint

...