Skip to content

Commit b966b33

Browse files
committed
menu async textEdit clear buffer on set
1 parent ca9e81e commit b966b33

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

examples/TextField/TextField/TextField.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using namespace Menu;
1010
//list of allowed characters
1111
char* const digit="0123456789";
1212
char* const hexChars MEMMODE="0123456789ABCDEF";
13-
char* const alphaNum[] MEMMODE = {" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
13+
char* const alphaNum[] MEMMODE = {" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,+-_"};
1414
//individual character validators
1515
char* constMEM validData[] MEMMODE={hexChars,hexChars,hexChars,hexChars};
1616

@@ -27,15 +27,17 @@ constMEM textFieldShadowRaw op1InfoRaw MEMMODE={
2727
noStyle,
2828
buf0,//edit buffer
2929
validIP,
30-
4
30+
4//this is the number of entries on validators array, not th efield length
3131
};//MEMMODE static stuff
3232
constMEM textFieldShadow& op1Info=*(textFieldShadow*)&op1InfoRaw;//hacking c++ to use progmem (hugly)
3333
textField option0(op1Info);
3434

3535
char buf1[]="0000";
36+
char name[]=" ";//field will initialize its size by this string length
3637
MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
3738
,OBJ(option0)
3839
,EDIT("Hex",buf1,validData,doNothing,noEvent,noStyle)
40+
,EDIT("Name",name,alphaNum,doNothing,noEvent,noStyle)
3941
,EXIT("<Exit")
4042
);
4143

examples/TextField/platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ lib_dir=~/Arduino/Libraries
1616
platform = atmelavr
1717
board = nanoatmega328
1818
framework = arduino
19-
upload_port=/dev/ttyUSB1
19+
upload_port=/dev/ttyUSB*
2020
upload_flags=-V
2121
build_flags = -Wno-comment -Wno-reorder -Wno-strict-aliasing -Wno-builtin-macro-redefined -DNODEBUG
2222

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.17.16
2+
version=4.17.17
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=Generic menu/interactivity system

src/items.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ void textField::doNav(navNode& nav,navCmd cmd) {
161161
dirty=true;
162162
} else {
163163
if(cursor<(idx_t)strlen(buffer())-1) cursor++;
164+
// if(cursor<sz()) cursor++;
164165
edited=false;
165166
}
166167
dirty=true;
@@ -325,6 +326,7 @@ bool textField::async(const char*uri,navRoot& root,idx_t lvl=0) {
325326
if ((!*uri)||(uri[0]=='/'&&!uri[1])) return true;
326327
if (uri[0]=='/') {
327328
StringStream i(++uri);
329+
memset(buffer(), validator(0)[0], (idx_t)strlen(buffer()));//clear buffer
328330
while(i.available()) parseInput(root.node(), i);
329331
trace(MENU_DEBUG_OUT<<"textField::enterCmd"<<endl);
330332
doNav(root.node(),escCmd);

0 commit comments

Comments
 (0)