MULTIPAGE: issue #2 of non-focusable page

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

    • MULTIPAGE: issue #2 of non-focusable page

      Hello again.

      There is a next issue with a non-focusable page (page, that does not contain focusable widgets) of MULTIPAGE.
      It concerns using the keyboard.

      A simple example demonstrates this issue.

      Using the keyboard (keys "PgUp", "PgDown"):

      1. Go to the Page 1 (using key "PgUp").
      2. Open the Dropdown list using key "Space".
      3. Press key "PgDown" to select next page. Press it again.

      As you see, there is no keyboard reaction because the MULTIPAGE has lost focus...

      Question: How to avoid this issue using currently available emWin? How to fix it properly?

      C Source Code

      1. #include "GUI.h"
      2. #include "MULTIPAGE.h"
      3. #define RECOMMENDED_MEMORY (1024L * 20)
      4. static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = {
      5. { WINDOW_CreateIndirect, NULL, 0, 0, 0, 260, 180, FRAMEWIN_CF_MOVEABLE },
      6. { TEXT_CreateIndirect, "Dialog 1", 0, 5, 10, 50, 20, TEXT_CF_LEFT },
      7. { DROPDOWN_CreateIndirect, NULL, GUI_ID_DROPDOWN1, 5, 30, 80, 50, 0},
      8. { BUTTON_CreateIndirect, "Button 1", GUI_ID_BUTTON0, 5, 60, 80, 20, 0},
      9. };
      10. static const GUI_WIDGET_CREATE_INFO _aDialogCreate2[] = {
      11. { WINDOW_CreateIndirect, NULL, 0, 0, 0, 260, 180, FRAMEWIN_CF_MOVEABLE },
      12. { TEXT_CreateIndirect, "Dialog 2", 0, 5, 10, 50, 20, TEXT_CF_LEFT },
      13. { TEXT_CreateIndirect, "Text 1", GUI_ID_TEXT0, 25, 30, 50, 15, TEXT_CF_LEFT },
      14. { TEXT_CreateIndirect, "Text 2", GUI_ID_TEXT1, 25, 50, 50, 15, TEXT_CF_LEFT },
      15. };
      16. static const GUI_WIDGET_CREATE_INFO _aDialogCreate3[] = {
      17. { WINDOW_CreateIndirect, NULL, 0, 0, 0, 260, 180, FRAMEWIN_CF_MOVEABLE },
      18. { TEXT_CreateIndirect, "Dialog 3", 0, 5, 10, 50, 20, TEXT_CF_LEFT },
      19. { RADIO_CreateIndirect, NULL, GUI_ID_RADIO0, 5, 30, 0, 0, 0, 3},
      20. { TEXT_CreateIndirect, "Option 1", GUI_ID_TEXT0, 25, 30, 50, 15, TEXT_CF_LEFT },
      21. { TEXT_CreateIndirect, "Option 2", GUI_ID_TEXT1, 25, 50, 50, 15, TEXT_CF_LEFT },
      22. { TEXT_CreateIndirect, "Option 3", GUI_ID_TEXT2, 25, 70, 50, 15, TEXT_CF_LEFT },
      23. };
      24. void MainTask(void) {
      25. WM_SetCreateFlags(WM_CF_MEMDEV);
      26. GUI_Init();
      27. if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY) {
      28. GUI_ErrorOut("Not enough memory available.");
      29. return;
      30. }
      31. WM_HWIN hFrameWin = FRAMEWIN_Create("FrameWindow", NULL, WM_CF_SHOW, 10, 20, 300, 200);
      32. WM_HWIN hClientWin = WM_GetClientWindow(hFrameWin);
      33. FRAMEWIN_SetClientColor(hFrameWin, GUI_GREEN);
      34. FRAMEWIN_SetMoveable(hFrameWin, 1);
      35. WM_HWIN hMultiPage = MULTIPAGE_CreateEx(5, 5, WM_GetWinSizeX(hClientWin) - 10, WM_GetWinSizeY(hClientWin) - 10, hClientWin, WM_CF_SHOW, 0, 0);
      36. WM_HWIN hDialog = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), NULL, WM_UNATTACHED, 0, 0);
      37. WM_HWIN hDropdown = WM_GetDialogItem(hDialog, GUI_ID_DROPDOWN1);
      38. DROPDOWN_AddString(hDropdown, "Item 1");
      39. DROPDOWN_AddString(hDropdown, "Item 2");
      40. DROPDOWN_AddString(hDropdown, "Item 3");
      41. MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 1");
      42. hDialog = GUI_CreateDialogBox(_aDialogCreate2, GUI_COUNTOF(_aDialogCreate2), NULL, WM_UNATTACHED, 0, 0);
      43. MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 2");
      44. hDialog = GUI_CreateDialogBox(_aDialogCreate3, GUI_COUNTOF(_aDialogCreate3), NULL, WM_UNATTACHED, 0, 0);
      45. MULTIPAGE_AddPage(hMultiPage, hDialog, "Page 3");
      46. while (1) {
      47. GUI_Delay(100);
      48. }
      49. }
      Display All
      Best regards,
      Volodymyr.
    • Hi Volodymyr,

      I'm sorry but unfortunately you will have to wait for the next emWin version to be released. By the way, owning an emWin license gives you the advantage to report bugs and obtain a fixed version.
      But you can try with this workaround for now: just add a button to your dialog with the non-focusable widgets and hide it using WM_HideWindow().

      Best regards,

      Florian
      Please read the forum rules before posting.

      Keep in mind, this is *not* a support forum.
      Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
      Should you be entitled to support you can contact us via our support system: segger.com/ticket/

      Or you can contact us via e-mail.