text click acknowledgement

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

    • Hi,

      Please note that the TEXT widget does not react on touch normally. Alos, this means that it will send no message to its parent window regarding touch input.

      But you can add reacting on touch manually. Add the code from 'case WM_TOUCH' to your TEXT widget callback 'ForceTextCallback'.

      C Source Code

      1. #include "DIALOG.h"
      2. /*********************************************************************
      3. *
      4. * Externals
      5. *
      6. **********************************************************************
      7. */
      8. /*********************************************************************
      9. *
      10. * Defines
      11. *
      12. **********************************************************************
      13. */
      14. #define ID_WINDOW_0 (GUI_ID_USER + 0x00)
      15. #define ID_TEXT_0 (GUI_ID_USER + 0x01)
      16. /*********************************************************************
      17. *
      18. * Static data
      19. *
      20. **********************************************************************
      21. */
      22. /*********************************************************************
      23. *
      24. * _aDialogCreate
      25. */
      26. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
      27. { WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 320, 240, 0, 0x0, 0 },
      28. { TEXT_CreateIndirect, "Click On Text", ID_TEXT_0, 20, 60, 120, 30, 0, 0x0, 0 },
      29. };
      30. /*********************************************************************
      31. *
      32. * Static code
      33. *
      34. **********************************************************************
      35. */
      36. /*********************************************************************
      37. *
      38. * _cbText
      39. */
      40. static void _cbText(WM_MESSAGE * pMsg) {
      41. GUI_PID_STATE * pState;
      42. static int Pressed;
      43. WM_MESSAGE Message;
      44. switch (pMsg->MsgId) {
      45. case WM_TOUCH:
      46. pState = (GUI_PID_STATE *)pMsg->Data.p;
      47. if (pState) {
      48. if (pState->Pressed) {
      49. if (Pressed == 0) {
      50. Message.Data.v = WM_NOTIFICATION_CLICKED;
      51. Message.hWinSrc = pMsg->hWin;
      52. Message.MsgId = WM_NOTIFY_PARENT;
      53. WM_SendMessage(WM_GetParent(pMsg->hWin), &Message);
      54. }
      55. Pressed = 1;
      56. } else if (Pressed) {
      57. Pressed = 0;
      58. Message.Data.v = WM_NOTIFICATION_RELEASED;
      59. Message.hWinSrc = pMsg->hWin;
      60. Message.MsgId = WM_NOTIFY_PARENT;
      61. WM_SendMessage(WM_GetParent(pMsg->hWin), &Message);
      62. }
      63. }
      64. break;
      65. default:
      66. TEXT_Callback(pMsg);
      67. break;
      68. }
      69. }
      70. /*********************************************************************
      71. *
      72. * _cbDialog
      73. */
      74. static void _cbDialog(WM_MESSAGE * pMsg) {
      75. WM_HWIN hItem;
      76. int NCode;
      77. int Id;
      78. switch (pMsg->MsgId) {
      79. case WM_INIT_DIALOG:
      80. //
      81. // Initialization of 'Window'
      82. //
      83. hItem = pMsg->hWin;
      84. WINDOW_SetBkColor(hItem, GUI_MAKE_COLOR(0x004080FF));
      85. //
      86. // Initialization of 'Click On Text'
      87. //
      88. hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
      89. TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
      90. TEXT_SetFont(hItem, GUI_FONT_20_1);
      91. //
      92. // Set a callback for the text widget to react on touch
      93. //
      94. WM_SetCallback(hItem, _cbText);
      95. break;
      96. case WM_NOTIFY_PARENT:
      97. Id = WM_GetId(pMsg->hWinSrc);
      98. NCode = pMsg->Data.v;
      99. switch (Id) {
      100. case ID_TEXT_0:
      101. switch (NCode) {
      102. case WM_NOTIFICATION_CLICKED:
      103. WINDOW_SetBkColor(pMsg->hWin, GUI_MAKE_COLOR(0x00FF8004));
      104. break;
      105. case WM_NOTIFICATION_RELEASED:
      106. WINDOW_SetBkColor(pMsg->hWin, GUI_MAKE_COLOR(0x004080FF));
      107. break;
      108. }
      109. break;
      110. }
      111. break;
      112. default:
      113. WM_DefaultProc(pMsg);
      114. break;
      115. }
      116. }
      117. /*********************************************************************
      118. *
      119. * Public code
      120. *
      121. **********************************************************************
      122. */
      123. /*********************************************************************
      124. *
      125. * MainTask
      126. */
      127. void MainTask(void) {
      128. GUI_Init();
      129. GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      130. while (1) {
      131. GUI_Delay(100);
      132. }
      133. }
      134. /*************************** End of file ****************************/
      Display All


      Regards
      Sven