The edit control in EnWin (Ucgui) is edited under numeric mode (decimal/16 binary/binary/floating-point number) and cannot be backspace using the BACKSPACE key, the main functions involved are:
Edit_setbinmode ()
Edit_setdecmode ()
Edit_sethexmode ()
Edit_setfloatmode ()
?
Once the edit control uses this class mode, the BACKSPACE key will not be deleted, and the workaround is to respond to the key message of the edit control, forcing the cursor to fall back to the previous character when the BACKSPACE key is received. Then use the interface function: Get the current character cursor position and set the specified character position cursor.
Edit_getcursorcharpos ()
Edit_setcursoratchar ()
?
Code:
/*********************************************************************
* Cbedit Edit Control callback
*/
Static void Cbedit (wm_message * pMsg) {
???? Switch (pMsg-MsgId) {
???? Case Wm_key:
???????? Switch ((wm_key_info *) (pMsg,Data. P),Key) {
???????? Case Gui_key_enter:
???????????? Price = edit_getfloatvalue(widgetsitembuf[0]);
???????????? Wm_setfocus (widgetsitembuf[1]);????
???????????? return;
???????? Case gui_key_backspace:
???????????? if ((wm_key_info *) (pMsg,Data. P),pressedcnt = = 0)
???????????? Edit_setcursoratchar (widgetsitembuf[0],edit_getcursorcharpos(widgetsitembuf[0])-1);
???????????? break;
????????}
???? break;
????}
???? Edit_callback (pMsg);
}
?
Operating effect:
EmWin (Ucgui) Edit Control backspace method worldsing