Saturday, December 16th 2017, 7:38pm 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.

minhbka

Beginner

Date of registration: Dec 6th 2017

Posts: 2

1

Wednesday, December 6th 2017, 9:10am

How to get image pressed event if window has two images which are same size and same position ?

Hi everybody!

My project have a window which has two images.
These images have same size, same position (at the center of window) and I call them as image_1 and image_2.
Firstly, I set image_1 with bitmap data bmp11, image_2 with bitmap data bmp_21.
Then, when I press on image_1, I want to change the bitmap data of both image_1 and image 2. from bmp11 to bmp12 for image_1 and from bmp21 to bmp22 for image_2.
The problem is that when I press on image_1, the data of those images are not changed. It seems I can not catch the image_1 pressed event. I guess that happens because image_1 and image_2 are in the same position and size.



Could you please help me to fix this problem? I also attach my source code for you to check.


Thank you!
minhbka has attached the following file:
  • Test.zip (23.85 kB - 8 times downloaded - Last download: Dec 14th 2017, 12:43am)

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 443

2

Wednesday, December 6th 2017, 10:16am

Hi,

Yes you are right. The topmost widget image_2 catches the input and it never get through to image_1.

Attached is your example with a small change which makes it working. You can either react on release of image_2 or react on both widgets in the 'same' case. Search for '/****/' to find my changes.

I had a good laugh once it was working. Didn't expected such an image.

Another point is that you set an empty BMP data. It is working but I don't recommend to do this. Better would be to set simply no image for image_2.

Regards
Sven
SEGGER - Schoenen has attached the following file:
  • Test.zip (22.63 kB - 10 times downloaded - Last download: Dec 14th 2017, 12:43am)

minhbka

Beginner

Date of registration: Dec 6th 2017

Posts: 2

3

Wednesday, December 6th 2017, 10:56am

I got it, thank you very much.