Description
I have an encoder input device with 2 buttons, one bound to ENTER KEY and the other to NEXT KEY.
I’m having trouble using message box with header and footer buttons.
It seems related to the editing mode, which is associated to encoder devices, natively.
The effect is that I can navigate smoothly within the buttons in the actual group, but I need to press ENTER KEY twice in order to launch the action associated to a button. The first click switches from navigate
to editing mode
, the second triggers the action.
Moreover, when in editing mode
, if the NEXT KEY is pressed again, the text of the button label is shifted by some pixels and the action can’t be launched any more.
What MCU/Processor/Board and compiler are you using?
Custom board based on NXP iMXRT1052, FreeRTOS V10.4.3 LTS Patch 2.
Working on IAR IDE.
What LVGL version are you using?
LVGL 9.1
What do you want to achieve?
I’d like to have one only click to trigger the action on message box buttons.
What have you tried so far?
I tried forcing the setting mode with the function lv_group_set_editing
, this seems to solve the problem of the single click, but not the one of the shift of the button label. In editing mode, pressing the NEXT KEY causes that shift. Is there a way to avoid this?
Code to reproduce
encoder_read
callback.
static void encoder_read(lv_indev_t * indev, lv_indev_data_t * data)
{
static BSP_GPIO_BUTTON_STATE advLastState = BSP_GPIO_BUTTON_NOT_PRESSED;
if ( (BSP_GPIO_BUTTON_Get(BSP_GPIO_BUTTON_ADV) == BSP_GPIO_BUTTON_NOT_PRESSED) && (advLastState == BSP_GPIO_BUTTON_PRESSED) )
{
advLastState = BSP_GPIO_BUTTON_NOT_PRESSED;
data->enc_diff = 1;
}
else if(BSP_GPIO_BUTTON_Get(BSP_GPIO_BUTTON_ADV) == BSP_GPIO_BUTTON_PRESSED)
{
advLastState = BSP_GPIO_BUTTON_PRESSED;
data->enc_diff = 0;
}
else
data->enc_diff = 0;
if (BSP_GPIO_BUTTON_Get(BSP_GPIO_BUTTON_PRG) == BSP_GPIO_BUTTON_PRESSED)
data->state = LV_INDEV_STATE_PRESSED;
else
data->state = LV_INDEV_STATE_RELEASED;
}
Screenshot and/or video
This is the shift upward after pressing the NEXT KEY in editing mode.