File tree Expand file tree Collapse file tree 4 files changed +6
-7
lines changed
Expand file tree Collapse file tree 4 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 1414 "dependencies" : {
1515 "name" : " M5Stack"
1616 },
17- "version" : " 0.2.2 " ,
17+ "version" : " 0.2.3 " ,
1818 "framework" : " arduino" ,
1919 "platforms" : " espressif32" ,
2020 "build" : {
Original file line number Diff line number Diff line change 11name =M5TreeView
2- version =0.2.2
2+ version =0.2.3
33author =lovyan03
44maintainer =Lovyan <
[email protected] >
55sentence =TreeView Menu UI for M5Stack
Original file line number Diff line number Diff line change 44#undef min
55#include < algorithm>
66
7- static bool btnALong = false ;
8-
97void 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
3735M5TreeView::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 ;
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments