EmWin (Ucgui) Edit Control backspace method worldsing

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.