Ver 5.38 - How to make FRAMEWIN or DIALOG untouchable (including all childs)?

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

    • Ver 5.38 - How to make FRAMEWIN or DIALOG untouchable (including all childs)?

      Hello.

      How to make FRAMEWIN or DIALOG untouchable (insensitive to all mouse/touchpad events including all child-widgets)?
      I know that Ver. 5.50 already has the function WM_SetUntouchable().

      But we are using 5.38.
      Best regards,
      Volodymyr.

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

    • Hi,

      In the callback function of a window which shouldn't be touchable you have to react on WM_TOUCH and forward the message to its parent.


      Just like:

      C Source Code

      1. case WM_TOUCH: {
      2. /*
      3. // Not sure if this required...
      4. GUI_PID_STATE * pState;
      5. pState = (GUI_PID_STATE *)pMsg->Data.p;
      6. if (pState) {
      7. pState->x += WM_GetWindowOrgX(pMsg->hWin);
      8. pState->y += WM_GetWindowOrgY(pMsg->hWin);
      9. }
      10. */
      11. WM_SendMessage(WM_GetParent(pMsg->hWin), pMsg);
      12. }
      13. break;
      Display All
      Didn't checked it, but it might be necessary to add the current windows origin to the coordinates.

      Regards,
      Sven
    • SEGGER - Schoenen wrote:

      Hi,

      In the callback function of a window which shouldn't be touchable you have to react on WM_TOUCH and forward the message to its parent.


      Just like:

      C Source Code

      1. case WM_TOUCH: {
      2. /*
      3. // Not sure if this required...
      4. GUI_PID_STATE * pState;
      5. pState = (GUI_PID_STATE *)pMsg->Data.p;
      6. if (pState) {
      7. pState->x += WM_GetWindowOrgX(pMsg->hWin);
      8. pState->y += WM_GetWindowOrgY(pMsg->hWin);
      9. }
      10. */
      11. WM_SendMessage(WM_GetParent(pMsg->hWin), pMsg);
      12. }
      13. break;
      Display All
      Didn't checked it, but it might be necessary to add the current windows origin to the coordinates.

      Regards,
      Sven
      Hello.

      I tried your sample, but it does not work or I do not understand something.

      Here is a small sample, there is a main window, there is a button on it, pressing this button creates another window (derived window).
      My problem is: after this another window is open, the PID-control (mouse/touch) for main window should be disabled, it should be untouchable (including its all widgets) until this second derived window will be closed.
      The behaviour of main window should be the same if I make a derived window as modal.

      Source Code

      1. #include "DIALOG.h"
      2. #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
      3. #define ID_DROPDOWN_0 (GUI_ID_USER + 0x01)
      4. #define ID_BUTTON_0 (GUI_ID_USER + 0x02)
      5. #define ID_DERIVED_0 (GUI_ID_USER + 0x03)
      6. #define ID_DERIVED_DROPDOWN_0 (GUI_ID_USER + 0x04)
      7. #define ID_DERIVED_BUTTON_0 (GUI_ID_USER + 0x05)
      8. static U8 isUntouched = 0;
      9. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
      10. { FRAMEWIN_CreateIndirect, "Main window", ID_FRAMEWIN_0, 0, 0, 200, 200, FRAMEWIN_CF_MOVEABLE, 0x0, 0 },
      11. { DROPDOWN_CreateIndirect, "Dropdown", ID_DROPDOWN_0, 10, 10, 80, 50, 0, 0x0, 0 },
      12. { BUTTON_CreateIndirect, "New window", ID_BUTTON_0, 100, 10, 80, 20, 0, 0x0, 0 },
      13. };
      14. static const GUI_WIDGET_CREATE_INFO _aDerivedDialogCreate[] = {
      15. { FRAMEWIN_CreateIndirect, "Derived window", ID_DERIVED_0, 80, 80, 150, 90, FRAMEWIN_CF_MOVEABLE, 0x0, 0 },
      16. { DROPDOWN_CreateIndirect, "Dropdown", ID_DERIVED_DROPDOWN_0, 10, 10, 80, 50, 0, 0x0, 0 },
      17. { BUTTON_CreateIndirect, "Close", ID_DERIVED_BUTTON_0, 10, 40, 80, 20, 0, 0x0, 0 },
      18. };
      19. static void setupDropdown(WM_HWIN hItem) {
      20. DROPDOWN_AddString(hItem, "Item 1");
      21. DROPDOWN_AddString(hItem, "Item 2");
      22. DROPDOWN_AddString(hItem, "Item 3");
      23. }
      24. static void _cbDerivedDialog(WM_MESSAGE * pMsg) {
      25. WM_HWIN hItem;
      26. int NCode;
      27. int Id;
      28. WM_KEY_INFO * pInfo = (WM_KEY_INFO *)pMsg->Data.p;
      29. switch (pMsg->MsgId) {
      30. case WM_INIT_DIALOG:
      31. setupDropdown(WM_GetDialogItem(pMsg->hWin, ID_DERIVED_DROPDOWN_0));
      32. break;
      33. case WM_NOTIFY_PARENT:
      34. switch (pMsg->Data.v) {
      35. case WM_NOTIFICATION_RELEASED:
      36. switch (WM_GetId(pMsg->hWinSrc)) {
      37. case ID_DERIVED_BUTTON_0:
      38. GUI_EndDialog(pMsg->hWin, 0);
      39. isUntouched = 0;
      40. break;
      41. }
      42. break;
      43. }
      44. break;
      45. default:
      46. WM_DefaultProc(pMsg);
      47. break;
      48. }
      49. }
      50. static void _cbDialog(WM_MESSAGE * pMsg) {
      51. WM_HWIN hItem;
      52. int NCode;
      53. int Id;
      54. WM_KEY_INFO * pInfo = (WM_KEY_INFO *)pMsg->Data.p;
      55. switch (pMsg->MsgId) {
      56. case WM_INIT_DIALOG:
      57. setupDropdown(WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0));
      58. break;
      59. case WM_TOUCH:
      60. if (isUntouched) {
      61. WM_SendMessage(WM_GetParent(pMsg->hWin), pMsg);
      62. break;
      63. }
      64. case WM_NOTIFY_PARENT:
      65. switch (pMsg->Data.v) {
      66. case WM_NOTIFICATION_RELEASED:
      67. switch (WM_GetId(pMsg->hWinSrc)) {
      68. case ID_BUTTON_0:
      69. isUntouched = 1;
      70. GUI_CreateDialogBox(_aDerivedDialogCreate, GUI_COUNTOF(_aDerivedDialogCreate), _cbDerivedDialog, WM_HBKWIN, 0, 0);
      71. break;
      72. }
      73. break;
      74. }
      75. break;
      76. default:
      77. WM_DefaultProc(pMsg);
      78. break;
      79. }
      80. }
      81. void MainTask(void) {
      82. GUI_Init();
      83. WM_SetBkWindowColor(GUI_GRAY);
      84. GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
      85. while (1) {
      86. GUI_Delay(100);
      87. };
      88. }
      Display All
      Best regards,
      Volodymyr.

      The post was edited 3 times, last by volodymyr ().