How to get GUI_SendKeyMsg event when I focused at EDIT widget?

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

  • How to get GUI_SendKeyMsg event when I focused at EDIT widget?

    Dear all:
    Here has a problem when I focused on an EDIT widget, I can't get any KeyMsg when I press button and sent to the queue. Have anybody can help me to solve this problem, thx.

    P.S. Myapplication for STemWin is only use keyboard not touch screen.

    C Source Code

    1. switch(Id) {
    2. case ID_EDIT_0: // Notifications sent by 'Edit'
    3. switch(NCode) {
    4. case WM_NOTIFICATION_CLICKED:
    5. // USER START (Optionally insert code for reacting on notification message)
    6. // USER END
    7. break;
    8. case WM_NOTIFICATION_RELEASED:
    9. // USER START (Optionally insert code for reacting on notification message)
    10. // USER END
    11. break;
    12. case WM_NOTIFICATION_VALUE_CHANGED:
    13. // USER START (Optionally insert code for reacting on notification message)
    14. // USER END
    15. break;
    16. // USER START (Optionally insert additional code for further notification handling)
    17. // USER END
    18. }
    19. break; }
    Display All
  • Hi,

    Unfortunately, you can not react on key messages like you react on e.g. value changed. To react on key messages you have to set a custom callback for the edit widget itself.

    Attached you will find a short example on how this can be done. It shows the custom callback and how to distinguish between the different keys.

    Regards
    Sven
    Files
    • KeyMsg.zip

      (1.08 kB, downloaded 346 times, last: )
  • Dear Sir:
    I have tried your code but it doesn't work well, please see attach pic. I set my BUTTON_ENTER value is 0x81A but i got KeyMsg on _cbEDIT0 is 0x10000000 they are doesn't match, could you solve these problem? Thanks.

    SEGGER - Schoenen wrote:

    Hi,

    Unfortunately, you can not react on key messages like you react on e.g. value changed. To react on key messages you have to set a custom callback for the edit widget itself.

    Attached you will find a short example on how this can be done. It shows the custom callback and how to distinguish between the different keys.

    Regards
    Sven
    Images
    • keymsg.png

      63.53 kB, 1,187×613, viewed 358 times
  • Hello Mr. Spock,

    You can use WM_GetParent(pMsg->hWin) and use the returned handle to delete the parent. The problem is that the background window doesn't 'know' how to redraw itself and the deleted dialog will be still visible.

    Set a callback function for the background window and the dialog will disappear after deleting.

    Like:

    C Source Code

    1. /*********************************************************************
    2. *
    3. * _cbBk
    4. */
    5. static void _cbBk(WM_MESSAGE * pMsg) {
    6. switch (pMsg->MsgId) {
    7. case WM_PAINT:
    8. GUI_SetBkColor(GUI_BLACK);
    9. GUI_Clear();
    10. break;
    11. default:
    12. WM_DefaultProc(pMsg);
    13. break;
    14. }
    15. }
    16. /*********************************************************************
    17. *
    18. * Public code
    19. *
    20. **********************************************************************
    21. */
    22. /*********************************************************************
    23. *
    24. * MainTask
    25. */
    26. void MainTask(void) {
    27. GUI_Init();
    28. WM_SetCallback(WM_HBKWIN, _cbBk);
    29. //
    30. // ...
    31. //
    32. }
    Display All



    Live long and prosper
    Sven