why the spinbox disable to receive the input focus when use the TAB key ?

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

  • My question is:
    I Create an sample Dialog in the Simulation use the code:

    static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    { FRAMEWIN_CreateIndirect, "FmKetyTest", ID_FRAMEWIN_0, 0, 0, 320, 240, 0, 0, 0 },
    { BUTTON_CreateIndirect, "Button", ID_BUTTON_0, 208, 86, 80, 20, 0, 0, 0 },
    { BUTTON_CreateIndirect, "Button", ID_BUTTON_1, 212, 161, 80, 20, 0, 0, 0 },

    { EDIT_CreateIndirect, "Edit", ID_EDIT_1, 34, 111, 80, 20, 0, 100, 0 },
    { CHECKBOX_CreateIndirect, "Checkbox", ID_CHECKBOX_0, 42, 169, 80, 20, 0, 0, 0 },
    { SPINBOX_CreateIndirect, "", ID_SPINBOX_1, 2, 2, 65, 40, 0, 0, 0 },
    { MULTIEDIT_CreateIndirect, "Edit", ID_EDIT_0, 31, 44, 80, 64, 0, 100, 0 },
    };
    WM_HWIN CreateFmKetyTest(void);
    WM_HWIN CreateFmKetyTest(void) {
    WM_HWIN hWin;
    hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), &_cbDialog, WM_HBKWIN, 0, 0);
    }
    when Dialog show,I press the Tab Key on the keybord,the BUTTON,EDIT,CHECKBOX,MULTIEDIT can receive the input foucs,but only the SPINBOX can not.
    :(
  • Hello,

    Thank you for the hint. I could reproduce this behavior. Somehow the SPINBOX widget does not receive the according message to gain the input focus. I will have to have a closer look at this. This will be fixed in the next emWin release version.

    For now I unfortunately can help you just with the following workaround:

    C Source Code

    1. #include "GUI.h"
    2. #include "DIALOG.h"
    3. static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
    4. { FRAMEWIN_CreateIndirect, "FrameWin", 0, 10, 10, 110, 120, 0, 0, 0 },
    5. { BUTTON_CreateIndirect, "Button", GUI_ID_BUTTON0, 10, 10, 80, 20, 0, 0, 0 },
    6. { BUTTON_CreateIndirect, "Button", GUI_ID_BUTTON1, 10, 40, 80, 20, 0, 0, 0 },
    7. { SPINBOX_CreateIndirect, "", GUI_ID_SPINBOX0, 10, 70, 80, 20, 0, 0, 0 },
    8. };
    9. /*********************************************************************
    10. *
    11. * _cbDialog
    12. */
    13. static void _cbDialog(WM_MESSAGE * pMsg) {
    14. GUI_PID_STATE State;
    15. GUI_RECT WinRect;
    16. WM_HWIN hSpin;
    17. int NCode;
    18. int Id;
    19. switch (pMsg->MsgId) {
    20. case WM_NOTIFY_PARENT:
    21. NCode = pMsg->Data.v;
    22. Id = WM_GetId(pMsg->hWinSrc);
    23. switch (NCode) {
    24. case WM_NOTIFICATION_LOST_FOCUS:
    25. if (Id == GUI_ID_BUTTON1) {
    26. hSpin = WM_GetDialogItem(pMsg->hWin, GUI_ID_SPINBOX0);
    27. WM_GetWindowRectEx(hSpin, &WinRect);
    28. State.x = WinRect.x0 + 5;
    29. State.y = WinRect.y0 + 5;
    30. State.Pressed = 1;
    31. State.Layer = 0;
    32. GUI_PID_StoreState(&State);
    33. State.Pressed = 0;
    34. GUI_PID_StoreState(&State);
    35. }
    36. break;
    37. }
    38. default:
    39. WM_DefaultProc(pMsg);
    40. }
    41. }
    42. /*********************************************************************
    43. *
    44. * MainTask
    45. */
    46. void MainTask(void) {
    47. WM_HWIN hWin;
    48. GUI_Init();
    49. hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
    50. while (1) {
    51. GUI_Delay(100);
    52. }
    53. }
    Display All

    This sample uses the dialog procedure to determine if the second button (Id == GUI_ID_BUTTON1) lost the focus. In this case two PID states are stored in the PID buffer to simulate click and release on the SPINBOX widget. This causes the SPINBOX to receive the focus. So this should enable the user to switch between all widgets included in the dialog.

    Best regards,
    Adrian