Edit cursor

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

    • Edit cursor

      Hello.
      I try to create settings menu.
      I use swipelist and edit items (in float mode), which attached to swipelist items.
      When i want to edit value in edit_widget, i call WM_SetFocus(edit_widget) and enter digits from keyboard.
      After input i press enter or escape to confirm or cancel input.
      In both cases i use WM_SetFocus(swipelist_widget) to remove focus from edit_widget and hide cursor.
      When i enter value at first time everything is going ok.

      But when i press enter second time (and call WM_SetFocus(edit_widget) again), i dont see the cursor.
      Wherein i can input digits. I can get and save values, but the cursor is hidden.

      Helps only recreate settings window. Probably recreate EDIT will help too, but i dont think its good idea.

      Help me please. Is it a bug or am i doing smth wrong?

      I use stm32h753BI and emwin v5.40

      UPDATE: at the moment I solved the problem as follows: together with WM_SetFocus(edit_widget) i call WM_SetFocus(settings_window) and cursor works ok

      The post was edited 1 time, last by Feelinglight: update ().

    • Hi,

      I tried to reproduce the behavior, but on my end it is working.

      Below is the code I used for testing. Pressing the button moves the focus to the edit widget. After pressing the enter key it looses the focus. Another press on the button and the edit gets the focus again. In every case the cursor will be shown. I remove the focus from the edit widget by setting the focus to the desktop window (WM_HBKWIN).

      C Source Code

      1. #include "DIALOG.h"
      2. #include <stdio.h>
      3. /*********************************************************************
      4. *
      5. * Externals
      6. *
      7. **********************************************************************
      8. */
      9. /*********************************************************************
      10. *
      11. * Types
      12. *
      13. **********************************************************************
      14. */
      15. /*********************************************************************
      16. *
      17. * Defines
      18. *
      19. **********************************************************************
      20. */
      21. /*********************************************************************
      22. *
      23. * Static data
      24. *
      25. **********************************************************************
      26. */
      27. /*********************************************************************
      28. *
      29. * Static code
      30. *
      31. **********************************************************************
      32. */
      33. /*********************************************************************
      34. *
      35. * _cbEdit
      36. */
      37. static void _cbEdit(WM_MESSAGE * pMsg) {
      38. WM_KEY_INFO * pInfo;
      39. switch (pMsg->MsgId) {
      40. case WM_KEY:
      41. EDIT_Callback(pMsg);
      42. pInfo = (WM_KEY_INFO *)pMsg->Data.p;
      43. if (pInfo) {
      44. if ((pInfo->Key == GUI_KEY_ENTER) && (pInfo->PressedCnt == 0)) {
      45. WM_SetFocus(WM_HBKWIN);
      46. }
      47. }
      48. break;
      49. default:
      50. EDIT_Callback(pMsg);
      51. break;
      52. }
      53. }
      54. /*********************************************************************
      55. *
      56. * _cbBk
      57. */
      58. static void _cbBk(WM_MESSAGE * pMsg) {
      59. WM_HWIN hItem;
      60. int NCode;
      61. int Id;
      62. switch (pMsg->MsgId) {
      63. case WM_PAINT:
      64. GUI_SetBkColor(GUI_BLACK);
      65. GUI_Clear();
      66. break;
      67. case WM_NOTIFY_PARENT:
      68. Id = WM_GetId(pMsg->hWinSrc);
      69. NCode = pMsg->Data.v;
      70. switch (Id) {
      71. case GUI_ID_BUTTON0:
      72. switch (NCode) {
      73. case WM_NOTIFICATION_RELEASED:
      74. hItem = WM_GetDialogItem(pMsg->hWin, GUI_ID_SWIPELIST0);
      75. hItem = WM_GetDialogItem(hItem, GUI_ID_EDIT0);
      76. WM_SetFocus(hItem);
      77. break;
      78. }
      79. break;
      80. }
      81. break;
      82. default:
      83. WM_DefaultProc(pMsg);
      84. break;
      85. }
      86. }
      87. /*********************************************************************
      88. *
      89. * Public code
      90. *
      91. **********************************************************************
      92. */
      93. /*********************************************************************
      94. *
      95. * MainTask
      96. */
      97. void MainTask(void) {
      98. WM_HWIN hSwipe;
      99. WM_HWIN hEdit;
      100. int i;
      101. char acItem[16];
      102. GUI_Init();
      103. WM_MULTIBUF_Enable(1);
      104. WM_SetCallback(WM_HBKWIN, _cbBk);
      105. hSwipe = SWIPELIST_CreateEx(10, 10, 120, 200, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_SWIPELIST0);
      106. for (i = 0; i < 10; i++) {
      107. sprintf(acItem, "Item %i", i);
      108. SWIPELIST_AddItem(hSwipe, acItem, 30);
      109. }
      110. hEdit = EDIT_CreateEx(0, 0, 80, 20, 0, WM_CF_SHOW, 0, GUI_ID_EDIT0, 30);
      111. WM_SetCallback(hEdit, _cbEdit);
      112. SWIPELIST_ItemAttachWindow(hSwipe, 0, hEdit, 30, 5);
      113. BUTTON_CreateEx(140, 10, 80, 20, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_BUTTON0);
      114. while (1) {
      115. GUI_Delay(100);
      116. }
      117. }
      118. /*************************** End of file ****************************/
      Display All

      Can you post an example which shows how to reproduce this?

      Regards,
      Sven
      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.