Custom widget sample questions

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • 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

    The post was edited 1 time, last by Bruno ().

  • 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 Source Code: 104

    1. case WM_TOUCH:
    2. if (pMsg->Data.p) {
    3. pState = (GUI_PID_STATE *)pMsg->Data.p;
    4. if (MyWidget.Pressed != pState->Pressed) {
    5. MyWidget.Pressed = pState->Pressed;
    6. WM_SetUserData(hWin, &MyWidget, sizeof(MYWIDGET_Obj));
    7. if (MyWidget.Pressed) {
    8. WM_SetFocus(hWin);
    9. }
    10. WM_InvalidateWindow(hWin);
    11. }
    12. } else {
    13. MyWidget.Pressed = 0;
    14. WM_SetUserData(hWin, &MyWidget, sizeof(MYWIDGET_Obj));
    15. WM_InvalidateWindow(hWin);
    16. }
    17. break;
    Display All


    Best regards,
    Bruno