Saturday, February 24th 2018, 4:43am 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.

Bruno

Beginner

Date of registration: Jul 18th 2013

Posts: 4

1

Thursday, September 5th 2013, 3:41pm

Custom widget sample questions

Hello,

While studying the custom widget sample application (WIDGET_CustomWidgetType.c) I noticed that touching the MYWIDGET widget and moving in pressed state outside the widget crashes the simulation.
In there anything that should be added to the custom widget sample to prevent the crash?

On a device (EA1788 with NXP built emWin libraries), the application doesn't crash but the MYWIDGET widget stays in pressed state even if I click the other widget (a button).
How to get the MYWIDGET widget out of the pressed state?

Best regards,
Bruno

This post has been edited 1 times, last edit by "Bruno" (Sep 5th 2013, 4:34pm)


Bruno

Beginner

Date of registration: Jul 18th 2013

Posts: 4

2

Thursday, September 5th 2013, 4:53pm

Hi,

It looks like the MYWIDGET widget receives in this case a WM_TOUCH event with (pMsg->Data.p == NULL) when leaving the widget in pressed state.

Modifying the sample as below solves both my problems:

C/C++ Source code

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
case WM_TOUCH:
	if (pMsg->Data.p) {
		pState = (GUI_PID_STATE *)pMsg->Data.p;
		if (MyWidget.Pressed != pState->Pressed) {
			MyWidget.Pressed = pState->Pressed;
			WM_SetUserData(hWin, &MyWidget, sizeof(MYWIDGET_Obj));
			if (MyWidget.Pressed) {
				WM_SetFocus(hWin);
			}
			WM_InvalidateWindow(hWin);
		}
	} else {
		MyWidget.Pressed = 0;
		WM_SetUserData(hWin, &MyWidget, sizeof(MYWIDGET_Obj));
		WM_InvalidateWindow(hWin);
	}
	break;


Best regards,
Bruno

Date of registration: May 26th 2009

Posts: 1,022

3

Friday, September 6th 2013, 9:09am

Hello Bruno,

Thank you for the hint. In fact this is a sample which might also require further modifications depending on the functionality the custom widget has to support.

Best regards,
Adrian

Similar threads