Skip to content

Commit 14a6203

Browse files
committed
fix choose bug
choose field was showing values on edit, and it should not. That was noticeable on U8G2.
1 parent d1fa279 commit 14a6203

File tree

7 files changed

+41
-8
lines changed

7 files changed

+41
-8
lines changed

examples/U8G2/U8G2/U8G2.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void setup() {
221221
#endif
222222
u8g2.begin();
223223
u8g2.setFont(fontName);
224-
u8g2.setBitmapMode(0);
224+
// u8g2.setBitmapMode(0);
225225

226226
//disable second option
227227
mainMenu[1].enabled=disabledStatus;

examples/U8x8/U8x8/U8x8.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,22 @@ const char* constMEM hexDigit MEMMODE="0123456789ABCDEF";
3737
const char* constMEM hexNr[] MEMMODE={"0","x",hexDigit,hexDigit};
3838
char buf1[]="0x11";//<-- menu will edit this text
3939

40+
int chooseTest=-1;
41+
CHOOSE(chooseTest,chooseMenu,"Choose",doNothing,noEvent,noStyle
42+
,VALUE("First",1,doNothing,noEvent)
43+
,VALUE("Second",2,doNothing,noEvent)
44+
,VALUE("Third",3,doNothing,noEvent)
45+
,VALUE("Last",-1,doNothing,noEvent)
46+
);
47+
4048
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
4149
,OP("Op1",doNothing,noEvent)
4250
,EDIT("Hex",buf1,hexNr,doNothing,noEvent,noStyle)
51+
,SUBMENU(chooseMenu)
4352
,EXIT("<Back")
4453
);
4554

46-
#define MAX_DEPTH 1
55+
#define MAX_DEPTH 2
4756

4857
MENU_OUTPUTS(out,MAX_DEPTH
4958
,SERIAL_OUT(Serial)

examples/UCGLib/UCGLib/UCGLib.ino

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,22 @@ const char* constMEM hexDigit MEMMODE="0123456789ABCDEF";
4343
const char* constMEM hexNr[] MEMMODE={"0","x",hexDigit,hexDigit};
4444
char buf1[]="0x11";//<-- menu will edit this text
4545

46+
int chooseTest=-1;
47+
CHOOSE(chooseTest,chooseMenu,"Choose",doNothing,noEvent,noStyle
48+
,VALUE("First",1,doNothing,noEvent)
49+
,VALUE("Second",2,doNothing,noEvent)
50+
,VALUE("Third",3,doNothing,noEvent)
51+
,VALUE("Last",-1,doNothing,noEvent)
52+
);
53+
4654
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
4755
,OP("Op1",doNothing,noEvent)
4856
,EDIT("Hex",buf1,hexNr,doNothing,noEvent,noStyle)
57+
,SUBMENU(chooseMenu)
4958
,EXIT("<Back")
5059
);
5160

52-
#define MAX_DEPTH 1
61+
#define MAX_DEPTH 2
5362

5463
//define colors
5564
#define BLACK {0,0,0}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ArduinoMenu library
2-
version=4.0.9
2+
version=4.0.10
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=AVR generic menu/interactivity system

src/items.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,15 @@ Used menuVariantBase::printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx
305305
out.print(this==&root.active()?':':' ');
306306
l--;
307307
#ifdef MENU_FMT_WRAPS
308-
if (out.fmtStart(type()==selectClass?menuOut::fmtSelect:menuOut::fmtChoose,root.node(),idx)==proceed) {
308+
if (out.fmtStart(type()==selectClass?menuOut::fmtSelect:menuOut::fmtChoose,root.node(),idx)==proceed) {
309309
#endif
310+
// Serial<<"variant ";
311+
// print_P(Serial,operator[](at).getText());
312+
// Serial<<endl;
310313
out.setColor(valColor,sel,prompt::enabled,ed);
311314
if (l>0) l-=operator[](at).printRaw(out,l);
312315
#ifdef MENU_FMT_WRAPS
313-
}
316+
}
314317
#endif
315318
#ifdef MENU_FMT_WRAPS
316319
out.fmtEnd(type()==selectClass?menuOut::fmtSelect:menuOut::fmtChoose,root.node(),idx);

src/items.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@
368368
#ifdef MENU_FMT_WRAPS
369369
virtual classes type() const {return chooseClass;}
370370
#endif
371+
Used printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr=0) override;
371372
result sysHandler(SYS_FUNC_PARAMS) override;
372373
bool changed(const navNode &nav,const menuOut& out,bool sub=true) override {
373374
return menuVariant<T>::changed(nav,out)||menuNode::changed(nav,out);
@@ -411,6 +412,14 @@
411412
void menuField<T>::printLow(menuOut& o) const {o.print(low());}
412413
#endif
413414

415+
template<typename T>
416+
Used choose<T>::printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr) {
417+
bool ed=this==root.navFocus;
418+
return ed?
419+
prompt::printTo(root,sel,out,idx,len,panelNr)
420+
:menuVariantBase::printTo(root,sel,out,idx,len,panelNr);
421+
}
422+
414423
template<typename T>
415424
Used toggle<T>::printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr) {
416425
return menuVariantBase::togglePrintTo(root,sel,out,idx,len,panelNr);

src/nav.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
}
138138
//async printMenu on arbitrary menuOut device
139139
Used printMenu(menuOut& o) const {
140-
_trace(Serial<<"navRoot::printMenu(menuOut& o)"<<endl);
140+
trace(Serial<<"navRoot::printMenu(menuOut& o)"<<endl);
141141
if ((active().sysStyles()&_parentDraw)&&level)
142142
return o.printMenu(path[level-1]);
143143
else return o.printMenu(node());
@@ -188,7 +188,10 @@
188188
};
189189

190190
#ifdef DEBUG
191-
inline Stream& operator<<(Stream&o,const navNode& p) {return o<<*(prompt*)p.target;}
191+
inline Stream& operator<<(Stream&o,const navNode& p) {
192+
o.print((__FlashStringHelper*)p.target->getText());
193+
return o;
194+
}
192195
inline Stream& operator<<(Stream&o,const navRoot& p) {return o<<p.node();}
193196
#endif
194197

0 commit comments

Comments
 (0)