Skip to content

Commit dd49e80

Browse files
committed
Modify: Execute onFocus when returning from callback function.
1 parent 6285216 commit dd49e80

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"name": "M5Stack"
1616
},
17-
"version": "0.2.2",
17+
"version": "0.2.3",
1818
"framework": "arduino",
1919
"platforms": "espressif32",
2020
"build": {

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=M5TreeView
2-
version=0.2.2
2+
version=0.2.3
33
author=lovyan03
44
maintainer=Lovyan <[email protected]>
55
sentence=TreeView Menu UI for M5Stack

src/M5TreeView.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
#undef min
55
#include <algorithm>
66

7-
static bool btnALong = false;
8-
97
void M5TreeView::begin() {
108
focusItem = Items[0];
119
for (uint16_t i = 0; i != Items.size(); ++i) {
@@ -35,13 +33,13 @@ M5TreeView::eCmd M5TreeView::checkKB(char key) {
3533
}
3634

3735
M5TreeView::eCmd M5TreeView::checkInput() {
36+
bool btnALong = M5.BtnA.pressedFor(msecHold);
3837
_msec = millis();
3938
M5.update();
4039
eCmd res = eCmd::NONE;
41-
bool btnA = M5.BtnA.isPressed();
4240
Button& btnB(swapBtnBC ? M5.BtnC : M5.BtnB);
4341
Button& btnC(swapBtnBC ? M5.BtnB : M5.BtnC);
44-
bool press = btnA || btnC.isPressed() || btnB.isPressed();
42+
bool press = M5.BtnA.isPressed() || btnB.isPressed() || btnC.isPressed();
4543
bool canRepeat = _repeat == 0 || (_msec - _msecLast + _repeat) >= (1 < _repeat ? msecRepeat : msecHold);
4644
if (canRepeat) {
4745
if (btnB.isPressed()) { res = eCmd::HOLD; }
@@ -50,7 +48,6 @@ M5TreeView::eCmd M5TreeView::checkInput() {
5048
else if (btnB.wasReleased()) { res = eCmd::ENTER; }
5149
else if (btnALong) { ++_repeat; res = eCmd::PREV; }
5250
}
53-
btnALong = M5.BtnA.pressedFor(msecHold);
5451
if (res == eCmd::NONE
5552
&& useFACES && Wire.requestFrom(0x08, 1)) {
5653
while (Wire.available()){
@@ -160,6 +157,7 @@ MenuItem* M5TreeView::update(bool redraw) {
160157
if (_redraw) {
161158
updateDest();
162159
erase(true);
160+
focusItem->onEnter();
163161
}
164162
}
165163
break;

src/MenuItem.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ bool MenuItem::focusEnter() {
215215
if (mi->callback) {
216216
mi->callback(focusItem);
217217
_btnDrawer.draw(true);
218+
focusItem->onFocus();
218219
}
219220
return true;
220221
}

0 commit comments

Comments
 (0)