2015-04-13 02:39 PM
I have a popup dialog that I load for some text entry. If I make it modal, the dialog procedure no longer gets 'pen up' events. If it is not modal, the user can interact with other things on the screen behind the dialog.
This dialog (built with the GUI builder) is meant to support data entry and with no pen up events, the last touched button remains active until a different button is pressed. Not only does this look crappy but it becomes impossible to enter double letter combinations. Below is the entire code for this example which consists of the beginnings of a QWERTY keyboard. (QWER only supported for now. ;) ) Is there a way to get full functionality for a Modal dialogue? Other suggestions for resolving this welcome! (Should I send my ownWM_NOTIFICATION_RELEASED events?) Thanks!/*********************************************************************
* *
* SEGGER Microcontroller GmbH & Co. KG *
* Solutions for real time microcontroller applications *
* *
**********************************************************************
* *
* C-file generated by: *
* *
* GUI_Builder for emWin version 5.26 *
* Compiled Aug 8 2014, 14:49:54 *
* (c) 2013 Segger Microcontroller GmbH & Co. KG *
* *
**********************************************************************
* *
* Internet: www.segger.com Support: support@segger.com *
* *
**********************************************************************
*/
// USER START (Optionally insert additional includes)
#include ''GUI.h''
#define ADD_STEMWIN 1 // include stuff that depends on STemWin from UI.h
#include ''UI.h''
// USER END
#include ''DIALOG.h''
/*********************************************************************
*
* Defines
*
**********************************************************************
*/
#define ID_FRAMEWIN_0 (GUI_ID_USER + 0x00)
#define ID_BUTTON_0 (GUI_ID_USER + 0x01)
#define ID_BUTTON_1 (GUI_ID_USER + 0x02)
#define ID_BUTTON_2 (GUI_ID_USER + 0x03)
#define ID_BUTTON_3 (GUI_ID_USER + 0x04)
#define ID_EDIT_0 (GUI_ID_USER + 0x05)
// USER START (Optionally insert additional defines)
#define addChar(c) EDIT_AddKey(editHandle, c)
// USER END
/*********************************************************************
*
* Static data
*
**********************************************************************
*/
// USER START (Optionally insert additional static data)
static WM_HWIN dialogHandle;
static WM_HWIN editHandle;
// USER END
/*********************************************************************
*
* _aDialogCreate
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, ''Framewin'', ID_FRAMEWIN_0, 0, 0, 480, 500, 0, 0x64, 0 },
{ BUTTON_CreateIndirect, ''Button'', ID_BUTTON_0, 1, 276, 46, 46, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, ''Button'', ID_BUTTON_1, 48, 276, 46, 46, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, ''Button'', ID_BUTTON_2, 94, 276, 46, 46, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, ''Button'', ID_BUTTON_3, 142, 276, 46, 46, 0, 0x0, 0 },
{ EDIT_CreateIndirect, ''Edit'', ID_EDIT_0, 30, 35, 408, 37, 0, 0x32, 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) {
WM_HWIN hItem;
int NCode;
int Id;
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'Framewin'
//
hItem = pMsg->hWin;
FRAMEWIN_SetText(hItem, ''Enter User Name'');
FRAMEWIN_SetFont(hItem, GUI_FONT_24B_1);
//
// Initialization of 'Button'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
BUTTON_SetText(hItem, ''Q'');
BUTTON_SetFont(hItem, GUI_FONT_32B_1);
//
// Initialization of 'Button'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
BUTTON_SetText(hItem, ''W'');
BUTTON_SetFont(hItem, GUI_FONT_32B_1);
//
// Initialization of 'Button'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
BUTTON_SetFont(hItem, GUI_FONT_32B_1);
BUTTON_SetText(hItem, ''E'');
//
// Initialization of 'Button'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3);
BUTTON_SetFont(hItem, GUI_FONT_32B_1);
BUTTON_SetText(hItem, ''R'');
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
EDIT_SetFont(hItem, GUI_FONT_32B_1);
// USER START (Optionally insert additional code for further widget initialization)
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
editHandle = hItem;
// USER END
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_0: // Notifications sent by 'Button'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
addChar('Q');
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_1: // Notifications sent by 'Button'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
addChar('W');
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_2: // Notifications sent by 'Button'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
addChar('E');
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_3: // Notifications sent by 'Button'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
addChar('R');
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_EDIT_0: // Notifications sent by 'Edit'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_VALUE_CHANGED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// 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
*/
static WM_HWIN CreateFramewin(void);
static WM_HWIN CreateFramewin(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
// USER START (Optionally insert additional public code)
void CreateUserNameDialog(void)
{
dialogHandle = CreateFramewin();
WM_MakeModal(dialogHandle);
}
// USER END
/*************************** End of file ****************************/
.
#stemwin-modal-dialog