Thursday, November 23rd 2017, 5:47pm UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

RodolfoDias

Beginner

Date of registration: Mar 3rd 2017

Posts: 15

1

Monday, May 8th 2017, 3:03pm

How to detect a click outside a window

Hi,

in my project I am using some windows as popups. They are half the area of the background window and are displayed centered in the screen. My problem is, I wanna close this popup when the user touches the screen outside the popup area, but I don't know how to detect this event. The best approach in my opinion is close the popup in its own callback, as it can be opened from any window it will be a bad design if I need to insert code in all windows that can be its background.

Any advice in how to implement this behaviour?

RodolfoDias

Beginner

Date of registration: Mar 3rd 2017

Posts: 15

2

Monday, May 8th 2017, 7:36pm

Further information

I have tried to implement the desired behaviour through the WM_TOUCH event. But I have noticed that this event is only received when the touch occurs inside the window. I am still missing the event that allow me to receive a touch performed outside the window.

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 421

3

Friday, May 12th 2017, 4:20pm

Hi,

With version 5.38 of emWin we introduced a finction named GUI_PID_SetHook(). This function allows the user to set a hook function which gets called every time a PID/Touch input gets send to emWin.

Attached is an example how you could check if the touch is outside a specific window.

If you are using a version before 5.38 you need to find another approach. In the sample I have used the function WM_Screen2hWin() which returns the handle of the window which lies under the input coordinates. Maybe this helps if using a version before 5.38.

Regards,
Sven
SEGGER - Schoenen has attached the following file: