Skip to content

Commit 8a2d053

Browse files
committed
toggle update event has to be sent by the parent
as they don't get navigation focus
1 parent 78a043e commit 8a2d053

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

examples/esp8266/WebMenu/platformio.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ build_flags =
3030
-DMENU_ASYNC
3131
-DMENU_FMT_WRAPS
3232
-DMENU_IDLE_BKGND
33-
-DNO_MENU_DEBUG
34-
-DNO_WEB_DEBUG
33+
-DMENU_DEBUG
34+
-DWEB_DEBUG
3535
-DMENU_SSID="\"r-site.net\"" -DMENU_PASS="\"rsite.2011\""
3636
src_build_flags = !echo "-Wno-write-strings -Wno-reorder -Wno-strict-aliasing -Wno-sign-compare -DLOC="$PLATFORMIO_LOC
3737

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

src/items.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,11 @@ Used prompt::printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,id
9696
_trace(Serial<<"root.path[lvl].sel==n:"<<(root.path[lvl].sel==n)<<endl);
9797
_trace(Serial<<"root.path[lvl+1].target==&operator[](n))):"<<(root.path[lvl+1].target==&operator[](n))<<endl);
9898
_trace(Serial<<"operator[](n).type()==toggleClass:"<<(operator[](n).type()==toggleClass)<<endl);
99+
bool toggleUpdate=operator[](n).type()==toggleClass&&strchr(uri,'/');
99100
if (!(
100101
//if updating a toggle to not toggle the value, was deffault action
101102
//but as we can't enter toggles this action would be preceeding every update otherwise.
102-
(operator[](n).type()==toggleClass&&strchr(uri,'/'))
103+
toggleUpdate
103104
||(root.level>lvl&&root.path[lvl].sel==n&&root.path[lvl+1].target==&operator[](n))
104105
)) {
105106
_trace(Serial<<"menuNode, escTo "<<lvl<<endl);
@@ -108,7 +109,10 @@ Used prompt::printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,id
108109
root.doNav(navCmd(idxCmd,n));
109110
}
110111
_trace(Serial<<"menuNode, proceed async"<<endl);
111-
return operator[](n).async(uri,root,lvl+1);
112+
operator[](n).async(uri,root,lvl+1);
113+
if (toggleUpdate)
114+
root.node().event(root.useUpdateEvent?updateEvent:enterEvent,n);
115+
return true;
112116
}
113117
const char* navTarget::typeName() const {return "navTarget";}
114118
#endif

src/itemsTemplates.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,18 @@ namespace Menu {
112112
_trace(Serial<<"selecting value by index!"<<endl);
113113
idx_t n=menuNode::parseUriNode(uri);
114114
_trace(MENU_DEBUG_OUT<<"n:"<<n<<" sel:"<<root.path[lvl].sel<<endl);
115-
menuVariant<T>::sync(n);//sync to index!
116-
root.node().event(root.useUpdateEvent?updateEvent:enterEvent);
115+
menuVariant<T>::sync(n);//sync to index n!
116+
// root.node().event(root.useUpdateEvent?updateEvent:enterEvent);
117117
return true;
118118
}
119119
//if not by index then do the toggle
120120
_trace(Serial<<"toggle proceed..."<<endl);
121-
bool r=prompt::async(uri,root,lvl);
122-
root.node().event(root.useUpdateEvent?updateEvent:enterEvent);
123-
return r;
121+
// root.doNav(navCmd(enterCmd));
122+
// return true;
123+
// bool r=prompt::async(uri,root,lvl);
124+
// root.node().event(root.useUpdateEvent?updateEvent:enterEvent);
125+
// return r;
126+
return prompt::async(uri,root,lvl);
124127
}
125128
#endif
126129

0 commit comments

Comments
 (0)