Using GUI_KEY_DELETE or GUI_KEY_BACKSPACE in EDIT Field

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

    • Using GUI_KEY_DELETE or GUI_KEY_BACKSPACE in EDIT Field

      Hi,

      I have a problem in EDIT-field used in decimal mode (EDIT_SetDecMode). In this mode the function GUI_StoreKeyMsg(GUI_KEY_BACKSPACE, 1) followed by GUI_StoreKeyMsg(GUI_KEY_BACKSPACE, 0) obviously have no effect to the edit-field.
      I made sure the field already has the focus and also the EDIT_Callback-function is called after setting up the Key.

      Can anybody help? Is it possible to use the backspace or delete in decimal-Mode of EDIT-field? ?(

      thx. :D

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

    • Hi,

      The EDIT doesn't react on GUI_KEY_BACKSPACE in decimal mode per default. But you can catch the WM_KEY message in the EDIT callback function.

      Try this:

      C Source Code

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * Externals
      5. *
      6. **********************************************************************
      7. */
      8. /*********************************************************************
      9. *
      10. * Defines
      11. *
      12. **********************************************************************
      13. */
      14. /*********************************************************************
      15. *
      16. * Static data
      17. *
      18. **********************************************************************
      19. */
      20. /*********************************************************************
      21. *
      22. * Static code
      23. *
      24. **********************************************************************
      25. */
      26. /*********************************************************************
      27. *
      28. * _cbBk
      29. */
      30. static void _cbBk(WM_MESSAGE * pMsg) {
      31. switch (pMsg->MsgId) {
      32. case WM_PAINT:
      33. GUI_SetBkColor(GUI_BLACK);
      34. GUI_Clear();
      35. break;
      36. default:
      37. WM_DefaultProc(pMsg);
      38. break;
      39. }
      40. }
      41. /*********************************************************************
      42. *
      43. * _cbEdit
      44. */
      45. static void _cbEdit(WM_MESSAGE * pMsg) {
      46. WM_KEY_INFO * pInfo;
      47. int Value;
      48. int NewValue;
      49. int Pos;
      50. switch (pMsg->MsgId) {
      51. case WM_KEY:
      52. pInfo = (WM_KEY_INFO *)pMsg->Data.p;
      53. if (pInfo) {
      54. if (pInfo->Key == GUI_KEY_BACKSPACE) {
      55. if (pInfo->PressedCnt == 0) {
      56. //
      57. // Add code here
      58. //
      59. }
      60. } else {
      61. EDIT_Callback(pMsg);
      62. }
      63. }
      64. break;
      65. default:
      66. EDIT_Callback(pMsg);
      67. break;
      68. }
      69. }
      70. /*********************************************************************
      71. *
      72. * Public code
      73. *
      74. **********************************************************************
      75. */
      76. /*********************************************************************
      77. *
      78. * MainTask
      79. */
      80. void MainTask(void) {
      81. WM_HWIN hEdit;
      82. GUI_Init();
      83. WM_SetCallback(WM_HBKWIN, _cbBk);
      84. hEdit = EDIT_CreateEx(10, 10, 80, 30, WM_HBKWIN, WM_CF_SHOW, 0, GUI_ID_EDIT0, 10);
      85. EDIT_SetDecMode(hEdit, 9999, 0, 10000, 0, GUI_EDIT_NORMAL);
      86. WM_SetCallback(hEdit, _cbEdit);
      87. WM_SetFocus(hEdit);
      88. while (1) {
      89. GUI_Delay(100);
      90. }
      91. }
      92. /*************************** End of file ****************************/
      Display All
      Regards,
      Sven