Focus issue on disabled form fields

This commit is contained in:
Bertrand Songis
2020-04-22 09:55:12 +02:00
parent 007d162768
commit f0a92962c1
23 changed files with 41 additions and 41 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ void CurveEdit::update()
bool CurveEdit::onTouchEnd(coord_t x, coord_t y) bool CurveEdit::onTouchEnd(coord_t x, coord_t y)
{ {
if (!hasFocus()) { if (!hasFocus()) {
setFocus(); setFocus(SET_FOCUS_DEFAULT);
} }
CurveKeyboard::show(this, isCustomCurve()); CurveKeyboard::show(this, isCustomCurve());
+2 -2
View File
@@ -42,7 +42,7 @@ FullScreenDialog::FullScreenDialog(uint8_t type, std::string title, std::string
}); });
#endif #endif
bringToTop(); bringToTop();
setFocus(); setFocus(SET_FOCUS_DEFAULT);
} }
void FullScreenDialog::paint(BitmapBuffer * dc) void FullScreenDialog::paint(BitmapBuffer * dc)
@@ -117,7 +117,7 @@ void FullScreenDialog::deleteLater()
{ {
#if !defined(HARDWARE_TOUCH) #if !defined(HARDWARE_TOUCH)
if (previousFocus) { if (previousFocus) {
previousFocus->setFocus(); previousFocus->setFocus(SET_FOCUS_DEFAULT);
} }
#endif #endif
+1 -1
View File
@@ -61,7 +61,7 @@ class GVarNumberEdit: public FormGroup
if (event == EVT_KEY_LONG(KEY_ENTER)) { if (event == EVT_KEY_LONG(KEY_ENTER)) {
killEvents(event); killEvents(event);
switchGVarMode(); switchGVarMode();
field->setFocus(); field->setFocus(SET_FOCUS_DEFAULT);
} }
else { else {
FormGroup::onEvent(event); FormGroup::onEvent(event);
+1 -1
View File
@@ -311,7 +311,7 @@ void ModelCurvesPage::build(FormWindow * window, int8_t focusIndex)
}); });
if (focusIndex == index) { if (focusIndex == index) {
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
} }
grid.spacer(button->height() + 5); grid.spacer(button->height() + 5);
+2 -2
View File
@@ -404,7 +404,7 @@ void ModelInputsPage::build(FormWindow * window, int8_t focusIndex)
while (inputIndex < MAX_EXPOS && line->chn == input && EXPO_VALID(line)) { while (inputIndex < MAX_EXPOS && line->chn == input && EXPO_VALID(line)) {
Button * button = new InputLineButton(window, grid.getFieldSlot(), inputIndex); Button * button = new InputLineButton(window, grid.getFieldSlot(), inputIndex);
if (focusIndex == inputIndex) if (focusIndex == inputIndex)
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
button->bringToTop(); button->bringToTop();
Menu * menu = new Menu(window); Menu * menu = new Menu(window);
@@ -465,7 +465,7 @@ void ModelInputsPage::build(FormWindow * window, int8_t focusIndex)
else { else {
auto button = new TextButton(window, grid.getLabelSlot(), getSourceString(MIXSRC_FIRST_INPUT + input)); auto button = new TextButton(window, grid.getLabelSlot(), getSourceString(MIXSRC_FIRST_INPUT + input));
if (focusIndex == inputIndex) if (focusIndex == inputIndex)
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
button->bringToTop(); button->bringToTop();
Menu * menu = new Menu(window); Menu * menu = new Menu(window);
@@ -389,7 +389,7 @@ void ModelLogicalSwitchesPage::build(FormWindow * window, int8_t focusIndex)
}); });
if (focusIndex == i) { if (focusIndex == i) {
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
} }
grid.spacer(button->height() + 5); grid.spacer(button->height() + 5);
+2 -2
View File
@@ -335,7 +335,7 @@ void ModelMixesPage::build(FormWindow * window, int8_t focusMixIndex)
while (mixIndex < MAX_MIXERS && mix->srcRaw > 0 && mix->destCh == ch) { while (mixIndex < MAX_MIXERS && mix->srcRaw > 0 && mix->destCh == ch) {
Button * button = new MixLineButton(window, grid.getFieldSlot(), mixIndex); Button * button = new MixLineButton(window, grid.getFieldSlot(), mixIndex);
if (focusMixIndex == mixIndex) if (focusMixIndex == mixIndex)
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
button->bringToTop(); button->bringToTop();
Menu * menu = new Menu(window); Menu * menu = new Menu(window);
@@ -399,7 +399,7 @@ void ModelMixesPage::build(FormWindow * window, int8_t focusMixIndex)
else { else {
auto button = new TextButton(window, grid.getLabelSlot(), getSourceString(MIXSRC_CH1 + ch)); auto button = new TextButton(window, grid.getLabelSlot(), getSourceString(MIXSRC_CH1 + ch));
if (focusMixIndex == mixIndex) if (focusMixIndex == mixIndex)
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
button->setPressHandler([=]() -> uint8_t { button->setPressHandler([=]() -> uint8_t {
button->bringToTop(); button->bringToTop();
Menu * menu = new Menu(window); Menu * menu = new Menu(window);
+1 -1
View File
@@ -205,7 +205,7 @@ void ModelOutputsPage::build(FormWindow * window, int8_t focusChannel)
}); });
if (focusChannel == ch) { if (focusChannel == ch) {
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
} }
grid.spacer(button->height() + 5); grid.spacer(button->height() + 5);
+2 -2
View File
@@ -310,13 +310,13 @@ class ModelCategoryPageBody: public FormWindow {
} }
} }
else { else {
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
} }
return 1; return 1;
}); });
if (selected == index) { if (selected == index) {
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
footer->setCurrentModel(model); footer->setCurrentModel(model);
} }
+8 -8
View File
@@ -201,7 +201,7 @@ class RegisterDialog: public Dialog {
this->deleteLater(); this->deleteLater();
return 0; return 0;
}); });
exitButton->setFocus(); exitButton->setFocus(SET_FOCUS_DEFAULT);
grid.nextLine(); grid.nextLine();
grid.spacer(PAGE_PADDING); grid.spacer(PAGE_PADDING);
@@ -239,7 +239,7 @@ class RegisterDialog: public Dialog {
FormField::link(uid, rxName); FormField::link(uid, rxName);
FormField::link(rxName, okButton); FormField::link(rxName, okButton);
FormField::link(okButton, exitButton); FormField::link(okButton, exitButton);
okButton->setFocus(); okButton->setFocus(SET_FOCUS_DEFAULT);
} }
else if (reusableBuffer.moduleSetup.pxx2.registerStep == REGISTER_OK) { else if (reusableBuffer.moduleSetup.pxx2.registerStep == REGISTER_OK) {
deleteLater(); deleteLater();
@@ -467,7 +467,7 @@ class TrainerModuleWindow : public FormGroup {
g_model.trainerData.mode = newValue; g_model.trainerData.mode = newValue;
update(); update();
SET_DIRTY(); SET_DIRTY();
moduleChoice->setFocus(); moduleChoice->setFocus(SET_FOCUS_DEFAULT);
}); });
moduleChoice->setAvailableHandler(isTrainerModeAvailable); moduleChoice->setAvailableHandler(isTrainerModeAvailable);
grid.nextLine(); grid.nextLine();
@@ -595,7 +595,7 @@ class ModuleWindow : public FormGroup {
SET_DIRTY(); SET_DIRTY();
// TODO resetModuleSettings(moduleIdx); // TODO resetModuleSettings(moduleIdx);
update(); update();
moduleChoice->setFocus(); moduleChoice->setFocus(SET_FOCUS_DEFAULT);
}); });
moduleChoice->setAvailableHandler([=](int8_t moduleType) { moduleChoice->setAvailableHandler([=](int8_t moduleType) {
return moduleIdx == INTERNAL_MODULE ? isInternalModuleAvailable(moduleType) : isExternalModuleAvailable(moduleType); return moduleIdx == INTERNAL_MODULE ? isInternalModuleAvailable(moduleType) : isExternalModuleAvailable(moduleType);
@@ -620,7 +620,7 @@ class ModuleWindow : public FormGroup {
g_model.moduleData[moduleIdx].subType = newValue; g_model.moduleData[moduleIdx].subType = newValue;
SET_DIRTY(); SET_DIRTY();
update(); update();
rfChoice->setFocus(); rfChoice->setFocus(SET_FOCUS_DEFAULT);
}); });
} }
else if (isModulePXX2(moduleIdx)) { else if (isModulePXX2(moduleIdx)) {
@@ -630,7 +630,7 @@ class ModuleWindow : public FormGroup {
g_model.moduleData[moduleIdx].subType = newValue; g_model.moduleData[moduleIdx].subType = newValue;
SET_DIRTY(); SET_DIRTY();
update(); update();
rfChoice->setFocus(); rfChoice->setFocus(SET_FOCUS_DEFAULT);
}); });
} }
#if defined(MULTIMODULE) #if defined(MULTIMODULE)
@@ -647,7 +647,7 @@ class ModuleWindow : public FormGroup {
resetMultiProtocolsOptions(moduleIdx); resetMultiProtocolsOptions(moduleIdx);
SET_DIRTY(); SET_DIRTY();
update(); update();
rfChoice->setFocus(); rfChoice->setFocus(SET_FOCUS_DEFAULT);
}); });
if (g_model.moduleData[moduleIdx].multi.customProto) { if (g_model.moduleData[moduleIdx].multi.customProto) {
@@ -833,7 +833,7 @@ class ModuleWindow : public FormGroup {
g_model.moduleData[moduleIdx].failsafeMode = newValue; g_model.moduleData[moduleIdx].failsafeMode = newValue;
SET_DIRTY(); SET_DIRTY();
update(); update();
failSafeChoice->setFocus(); failSafeChoice->setFocus(SET_FOCUS_DEFAULT);
}); });
if (g_model.moduleData[moduleIdx].failsafeMode == FAILSAFE_CUSTOM) { if (g_model.moduleData[moduleIdx].failsafeMode == FAILSAFE_CUSTOM) {
new TextButton(this, grid.getFieldSlot(2, 1), STR_SET, new TextButton(this, grid.getFieldSlot(2, 1), STR_SET,
+1 -1
View File
@@ -467,7 +467,7 @@ void ModelTelemetryPage::build(FormWindow * window, int8_t focusSensorIndex)
return 0; return 0;
}); });
if (focusSensorIndex == idx) { if (focusSensorIndex == idx) {
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
} }
grid.nextLine(); grid.nextLine();
} }
+1 -1
View File
@@ -70,7 +70,7 @@ Page::~Page()
void Page::deleteLater() void Page::deleteLater()
{ {
if (previousFocus) { if (previousFocus) {
previousFocus->setFocus(); previousFocus->setFocus(SET_FOCUS_DEFAULT);
} }
Window::deleteLater(); Window::deleteLater();
+1 -1
View File
@@ -104,7 +104,7 @@ RadioCalibrationPage::RadioCalibrationPage(bool initial):
{ {
buildHeader(&header); buildHeader(&header);
buildBody(&body); buildBody(&body);
setFocus(); setFocus(SET_FOCUS_DEFAULT);
} }
void RadioCalibrationPage::buildHeader(Window * window) void RadioCalibrationPage::buildHeader(Window * window)
+1 -1
View File
@@ -66,5 +66,5 @@ RadioAnalogsDiagsPage::RadioAnalogsDiagsPage():
{ {
buildHeader(&header); buildHeader(&header);
buildBody(&body); buildBody(&body);
setFocus(); setFocus(SET_FOCUS_DEFAULT);
} }
+1 -1
View File
@@ -126,5 +126,5 @@ RadioKeyDiagsPage::RadioKeyDiagsPage() :
{ {
buildHeader(&header); buildHeader(&header);
buildBody(&body); buildBody(&body);
setFocus(); setFocus(SET_FOCUS_DEFAULT);
} }
+4 -4
View File
@@ -106,7 +106,7 @@ class BluetoothConfigWindow : public FormGroup
g_eeGeneral.bluetoothMode = newValue; g_eeGeneral.bluetoothMode = newValue;
update(); update();
SET_DIRTY(); SET_DIRTY();
btMode->setFocus(); btMode->setFocus(SET_FOCUS_DEFAULT);
}); });
grid.nextLine(); grid.nextLine();
@@ -158,7 +158,7 @@ void RadioHardwarePage::build(FormWindow * window)
calib->setPressHandler([=]() -> uint8_t { calib->setPressHandler([=]() -> uint8_t {
auto calibrationPage = new RadioCalibrationPage(); auto calibrationPage = new RadioCalibrationPage();
calibrationPage->setCloseHandler([=]() { calibrationPage->setCloseHandler([=]() {
calib->setFocus(); calib->setFocus(SET_FOCUS_DEFAULT);
}); });
return 0; return 0;
}); });
@@ -254,7 +254,7 @@ void RadioHardwarePage::build(FormWindow * window)
debugAnas->setPressHandler([=]() -> uint8_t { debugAnas->setPressHandler([=]() -> uint8_t {
auto debugAnalogsPage = new RadioAnalogsDiagsPage(); auto debugAnalogsPage = new RadioAnalogsDiagsPage();
debugAnalogsPage->setCloseHandler([=]() { debugAnalogsPage->setCloseHandler([=]() {
calib->setFocus(); calib->setFocus(SET_FOCUS_DEFAULT);
}); });
return 0; return 0;
}); });
@@ -263,7 +263,7 @@ void RadioHardwarePage::build(FormWindow * window)
debugKeys->setPressHandler([=]() -> uint8_t { debugKeys->setPressHandler([=]() -> uint8_t {
auto debugKeysPage = new RadioKeyDiagsPage(); auto debugKeysPage = new RadioKeyDiagsPage();
debugKeysPage->setCloseHandler([=]() { debugKeysPage->setCloseHandler([=]() {
calib->setFocus(); calib->setFocus(SET_FOCUS_DEFAULT);
}); });
return 0; return 0;
}); });
@@ -52,7 +52,7 @@ class SpectrumFooterWindow: public FormGroup
SET_VALUE(reusableBuffer.spectrumAnalyser.track, newValue * 1000000)); SET_VALUE(reusableBuffer.spectrumAnalyser.track, newValue * 1000000));
tracker->setSuffix("MHz"); tracker->setSuffix("MHz");
tracker->setPrefix("T: "); tracker->setPrefix("T: ");
tracker->setFocus(); tracker->setFocus(SET_FOCUS_DEFAULT);
if (isModuleMultimodule(moduleIdx)) { if (isModuleMultimodule(moduleIdx)) {
char label[10]; char label[10];
+1 -1
View File
@@ -100,7 +100,7 @@ class LayoutChoice: public FormField {
menu->setCloseHandler([=]() { menu->setCloseHandler([=]() {
editMode = false; editMode = false;
setFocus(); setFocus(SET_FOCUS_DEFAULT);
}); });
} }
+2 -2
View File
@@ -108,7 +108,7 @@ void SourceChoice::openMenu()
menu->setToolbar(new SourceChoiceMenuToolbar(this, menu)); menu->setToolbar(new SourceChoiceMenuToolbar(this, menu));
menu->setCloseHandler([=]() { menu->setCloseHandler([=]() {
editMode = false; editMode = false;
setFocus(); setFocus(SET_FOCUS_DEFAULT);
}); });
} }
@@ -132,7 +132,7 @@ void SourceChoice::onEvent(event_t event)
bool SourceChoice::onTouchEnd(coord_t, coord_t) bool SourceChoice::onTouchEnd(coord_t, coord_t)
{ {
openMenu(); openMenu();
setFocus(); setFocus(SET_FOCUS_DEFAULT);
setEditMode(true); setEditMode(true);
return true; return true;
} }
+1 -1
View File
@@ -480,7 +480,7 @@ void SpecialFunctionsPage::build(FormWindow * window, int8_t focusIndex)
}); });
if (focusIndex == i) { if (focusIndex == i) {
button->setFocus(); button->setFocus(SET_FOCUS_DEFAULT);
} }
grid.spacer(button->height() + 5); grid.spacer(button->height() + 5);
+2 -2
View File
@@ -93,7 +93,7 @@ void SwitchChoice::openMenu()
menu->setToolbar(new SwitchChoiceMenuToolbar(this, menu)); menu->setToolbar(new SwitchChoiceMenuToolbar(this, menu));
menu->setCloseHandler([=]() { menu->setCloseHandler([=]() {
editMode = false; editMode = false;
setFocus(); setFocus(SET_FOCUS_DEFAULT);
}); });
} }
@@ -117,7 +117,7 @@ void SwitchChoice::onEvent(event_t event)
bool SwitchChoice::onTouchEnd(coord_t, coord_t) bool SwitchChoice::onTouchEnd(coord_t, coord_t)
{ {
openMenu(); openMenu();
setFocus(); setFocus(SET_FOCUS_DEFAULT);
setEditMode(true); setEditMode(true);
return true; return true;
} }
+2 -2
View File
@@ -140,7 +140,7 @@ void TabsGroup::setVisibleTab(PageTab * tab)
currentTab = tab; currentTab = tab;
tab->build(&body); tab->build(&body);
if (!focusWindow) if (!focusWindow)
setFocus(); setFocus(SET_FOCUS_DEFAULT);
header.setTitle(tab->title.c_str()); header.setTitle(tab->title.c_str());
invalidate(); invalidate();
} }
@@ -170,7 +170,7 @@ void TabsGroup::onEvent(event_t event)
} }
else if (event == EVT_KEY_LONG(KEY_EXIT) || event == EVT_KEY_BREAK(KEY_EXIT)) { else if (event == EVT_KEY_LONG(KEY_EXIT) || event == EVT_KEY_BREAK(KEY_EXIT)) {
killEvents(event); killEvents(event);
ViewMain::instance->setFocus(); ViewMain::instance->setFocus(SET_FOCUS_DEFAULT);
deleteLater(); deleteLater();
} }
else if (parent) { else if (parent) {
+2 -2
View File
@@ -24,7 +24,7 @@
#include "strhelpers.h" #include "strhelpers.h"
TimeEdit::TimeEdit(Window * parent, const rect_t & rect, int32_t vmin, int32_t vmax, std::function<int32_t()> getValue, std::function<void(int32_t)> setValue): TimeEdit::TimeEdit(Window * parent, const rect_t & rect, int32_t vmin, int32_t vmax, std::function<int32_t()> getValue, std::function<void(int32_t)> setValue):
BaseNumberEdit(parent, rect, vmin, vmax, getValue, setValue) BaseNumberEdit(parent, rect, vmin, vmax, std::move(getValue), std::move(setValue))
{ {
} }
@@ -78,7 +78,7 @@ void TimeEdit::onEvent(event_t event)
bool TimeEdit::onTouchEnd(coord_t x, coord_t y) bool TimeEdit::onTouchEnd(coord_t x, coord_t y)
{ {
if (!hasFocus()) { if (!hasFocus()) {
setFocus(); setFocus(SET_FOCUS_DEFAULT);
} }
// NumberKeyboard * keyboard = NumberKeyboard::instance(); // NumberKeyboard * keyboard = NumberKeyboard::instance();