TcMenu / tcMenuLib

TcMenu modular IoT menu library supporting rotary encoder, joysticks, many displays, and remote control over Ethernet and Serial
Apache License 2.0
111 stars 10 forks source link

Dialog pre-selects a wrong button #208

Closed vzahradnik closed 11 months ago

vzahradnik commented 12 months ago

Describe the bug When creating a dialog, I set OK and Cancel button (in this exact order). I explicitly set the first button to be the active one, yet "Cancel" is pre-selected.

Confirm that the bug is in the embedded library It is.

To Reproduce Use the following code:

withMenuDialogIfAvailable([](MenuBasedDialog* dlg) {
    dlg->setButtons(BTNTYPE_OK, BTNTYPE_CANCEL, 0);
    dlg->show(TC_I18N_SETTINGS_MEMORY_SAVE_SETTINGS_DLG_TITLE, true, [](ButtonType buttonPressed, void* yourData) {
        if (buttonPressed == BTNTYPE_OK) {
            storeManager.saveSettings();
        }
    });
    dlg->copyIntoBuffer(TC_I18N_SETTINGS_MEMORY_SAVE_SETTINGS_DLG_MESSAGE);
});

Expected behavior OK button is pre-selected.

Screenshots image

Device Specs

davetcc commented 11 months ago

This has been mainly fixed now, I think there is one case left to handle, and that is when a menu based dialog is shown when returning from a custom drawing routine. This seems to leave the wrong item selected.

Steps that reproduce:

  1. Display has timed out to a dashboard instead of presenting a menu, IE the display has been taken over
  2. A remote pairing request arrives that causes a dialog to be presented, therefore ending the display take over.
  3. When the dialog appears, no item we be active.
davetcc commented 11 months ago

@vzahradnik closing this as I've tested it fairly thoroughly now, but if you find any issue still remaining please raise.