Hey, i'd like to create a dropdown. SO i used the GUI Builder to create the skeleton code.
My idea is: when the user presses the dropdown the list is supposed to expand, when the user presses somewhere outside the dropdown, the list should collapse.
Now i'm only receiving WM_NOTIFICATION_LOST_FOCUS events in my callback routine. The Event WM_NOTIFICATION_CLICKED never occurs. Does anybody know why?
Display All
my display thread looks like this
Display All
The GUI_TOUCH_StoreStateEx() is called in a separate thread every 25ms to get the newest touched coordinates (that part works, since i'm receiving events)
Now my question is, how can i expand the dropdown list when pressing on it?
Thx for your help
My idea is: when the user presses the dropdown the list is supposed to expand, when the user presses somewhere outside the dropdown, the list should collapse.
Now i'm only receiving WM_NOTIFICATION_LOST_FOCUS events in my callback routine. The Event WM_NOTIFICATION_CLICKED never occurs. Does anybody know why?
C Source Code
- /*********************************************************************
- * *
- * SEGGER Microcontroller GmbH & Co. KG *
- * Solutions for real time microcontroller applications *
- * *
- **********************************************************************
- * *
- * C-file generated by: *
- * *
- * GUI_Builder for emWin version 5.32 *
- * Compiled Oct 8 2015, 11:59:02 *
- * (c) 2015 Segger Microcontroller GmbH & Co. KG *
- * *
- **********************************************************************
- * *
- * Internet: www.segger.com Support: support@segger.com *
- * *
- **********************************************************************
- */
- // USER START (Optionally insert additional includes)
- #include "FramewinDLG_new.h"
- #include "cmsis_os.h"
- // USER END
- /*********************************************************************
- *
- * Defines
- *
- **********************************************************************
- */
- #define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
- #define ID_DROPDOWN_0 (GUI_ID_USER + 0x04)
- // USER START (Optionally insert additional defines)
- ///Maximale Breite des Displays
- #define X_MAX 240
- ///Maximale Höhe des Displays
- #define Y_MAX 320
- //
- // Recommended memory to run the sample with adequate performance
- //
- #define RECOMMENDED_MEMORY (1024L * 2)
- // USER END
- /*********************************************************************
- *
- * Static data
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static data)
- // USER END
- /*********************************************************************
- *
- * _aDialogCreate
- */
- static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] =
- {
- { FRAMEWIN_CreateIndirect, "Framewin", ID_FRAMEWIN_0, 0, 0, X_MAX, Y_MAX, 0, 0x0, 0 },
- { DROPDOWN_CreateIndirect, "Dropdown_menu", ID_DROPDOWN_0, 0, 0, 144, 25, 0, 0x0, 0 },
- // USER START (Optionally insert additional widgets)
- // USER END
- };
- /*********************************************************************
- *
- * Static code
- *
- **********************************************************************
- */
- // USER START (Optionally insert additional static code)
- // USER END
- /*********************************************************************
- *
- * _cbDialog
- */
- static void _cbDialog(WM_MESSAGE * pMsg)
- {
- //TODO weg
- volatile uint8_t test = 0;
- WM_HWIN hItem;
- int NCode;
- int Id;
- // USER START (Optionally insert additional variables)
- // USER END
- switch (pMsg->MsgId)
- {
- case WM_INIT_DIALOG:
- //
- // Initialization of 'Dropdown_menu'
- //
- hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
- DROPDOWN_SetFont(hItem, GUI_FONT_20_1);
- DROPDOWN_AddString(hItem, "Show Menue");
- DROPDOWN_AddString(hItem, "Show Ike");
- DROPDOWN_AddString(hItem, "Show Sensor Values");
- // USER START (Optionally insert additional code for further widget initialization)
- // USER END
- break;
- case WM_NOTIFY_PARENT:
- test++;
- test += 11;
- test -= 9;
- Id = WM_GetId(pMsg->hWinSrc);
- NCode = pMsg->Data.v;
- switch (Id)
- {
- case ID_DROPDOWN_0: // Notifications sent by 'Dropdown_menu'
- switch (NCode)
- {
- case WM_NOTIFICATION_CLICKED:
- // USER START (Optionally insert code for reacting on notification message)
- hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
- test++;
- test += 4;
- test--;
- DROPDOWN_Expand(hItem);
- // USER END
- break;
- case WM_NOTIFICATION_RELEASED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- case WM_NOTIFICATION_SEL_CHANGED:
- // USER START (Optionally insert code for reacting on notification message)
- // USER END
- break;
- // USER START (Optionally insert additional code for further notification handling)
- case WM_NOTIFICATION_LOST_FOCUS:
- // USER START (Optionally insert code for reacting on notification message)
- hItem = WM_GetDialogItem(pMsg->hWin, ID_DROPDOWN_0);
- test++;
- test += 4;
- test--;
- DROPDOWN_Collapse(hItem);
- // USER END
- }
- break;
- // USER START (Optionally insert additional code for further Ids)
- // USER END
- }
- break;
- // USER START (Optionally insert additional message handling)
- // USER END
- default:
- WM_DefaultProc(pMsg);
- break;
- }
- }
- /*********************************************************************
- *
- * Public code
- *
- **********************************************************************
- */
- /*********************************************************************
- *
- * CreateFramewin
- */
- WM_HWIN CreateFramewin_new(void)
- {
- WM_HWIN hWin;
- //
- // Check if recommended memory for the sample is available
- //
- if (GUI_ALLOC_GetNumFreeBytes() < RECOMMENDED_MEMORY)
- {
- GUI_ErrorOut("Not enough memory available.");
- return 0;
- }
- hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
- return hWin;
- }
- // USER START (Optionally insert additional public code)
- // USER END
- /*************************** End of file ****************************/
my display thread looks like this
Source Code
- void DisplayThread(void const * argument)
- {
- //Display Init.
- GUI_Init();
- CreateFramewin_new();
- const size_t nMax = 32;
- uint8_t * touchcoords[nMax];
- for (;;)
- {
- snprintf((char *) touchcoords, nMax, "X: %04d, Y: %04d", touchX, touchY);
- GUI_DispStringAt((char *) touchcoords, 0, 0);
- WM_Exec();
- osDelay(500);
- }
- }
The GUI_TOUCH_StoreStateEx() is called in a separate thread every 25ms to get the newest touched coordinates (that part works, since i'm receiving events)
Now my question is, how can i expand the dropdown list when pressing on it?
Thx for your help