@@ -280,11 +280,12 @@ MenuItem* MenuItem::draw(bool force, const Rect16* cursorRect, const Rect16* old
280280 }
281281
282282 if (_parentItem && _parentItem->rect .intersectsWith (rect)) {
283- if (_parentItem && _parentItem->rect .right () > rtmp.x ) {
283+ if (0 < rtmp. h && _parentItem && _parentItem->rect .right () > rtmp.x ) {
284284 Rect16 r = rtmp;
285285 r.w -= _parentItem->rect .right () - r.x ;
286286 r.x = _parentItem->rect .right ();
287- M5.Lcd .fillRect (r.x , r.y , r.w , r.h , backColor[0 ]);
287+ if (r.w > 0 )
288+ M5.Lcd .fillRect (r.x , r.y , r.w , r.h , backColor[0 ]);
288289 }
289290
290291 if (_parentItem && _parentItem->rect .bottom () > rtmp.y ) {
@@ -300,15 +301,16 @@ MenuItem* MenuItem::draw(bool force, const Rect16* cursorRect, const Rect16* old
300301 if (0 < rtmp.h && 0 < rtmp.w ) {
301302 bool cursor = cursorRect && cursorRect->intersectsWith (rtmp);
302303 // fill item body
303- if (cursor) {
304+ if (cursor) {
304305 Rect16 r = rtmp.intersect (*cursorRect);
305- if (0 < r.h ) { // fill cursor color
306- M5.Lcd .fillRect (rtmp.x , r.y , rtmp.w , r.h , backColor[1 ]);
307- }
308- if (cursorRect->y < rtmp.y ) {
309- M5.Lcd .fillRect (rtmp.x , r.bottom (), rtmp.w , rtmp.bottom () - cursorRect->bottom (), backColor[0 ]);
310- } else if (cursorRect->y > rtmp.y ) {
311- M5.Lcd .fillRect (rtmp.x , rtmp.y , rtmp.w , cursorRect->y - rtmp.y , backColor[0 ]);
306+ if (0 < r.h ) {
307+ if (rtmp.y < r.y ) {
308+ M5.Lcd .fillRect (rtmp.x , rtmp.y , rtmp.w , r.y - rtmp.y , backColor[0 ]);
309+ }
310+ if (rtmp.bottom () > r.bottom ()) {
311+ M5.Lcd .fillRect (rtmp.x , r.bottom (), rtmp.w , rtmp.bottom () - r.bottom (), backColor[0 ]);
312+ }
313+ M5.Lcd .fillRect (rtmp.x , r.y , rtmp.w , r.h , backColor[1 ]); // fill cursor color
312314 }
313315 } else {
314316 M5.Lcd .fillRect (rtmp.x , rtmp.y , rtmp.w , rtmp.h , backColor[0 ]);
0 commit comments