neu-rah / ArduinoMenu

Arduino generic menu/interactivity system
GNU Lesser General Public License v2.1
933 stars 189 forks source link

2nd menu item is disabled, swap with the first, and still it is the second that is disabled #295

Closed grandlizardofthecanyons closed 4 years ago

grandlizardofthecanyons commented 4 years ago

I took several of the examples and merged them to test with two keypads (one with up down and select, and the other as a numeric keypad) and a 20x4 LCD. I'm so glad you had examples to work with that can get me as far as this does, but I am having an issue that is quirky and I don't understand why it behaves this way.

I'm using this code with each object defined exactly as in your examples:

MENU(mainMenu,mainMenu_text,doNothing,noEvent,wrapStyle
  ,OP("Op1",action1,anyEvent)
  ,OP("Op2",action2,enterEvent)
  ,FIELD(test,"Test","%",0,100,10,1,doNothing,noEvent,wrapStyle)
  ,BARFIELD(test,"Bar field","%",0,100,10,1,doNothing,noEvent,wrapStyle)//numeric field with a bar
  ,FIELD(test,"Original","%",0,100,10,1,doNothing,noEvent,wrapStyle)//normal numeric field (2 edit levels)
  ,FIELD(test,"O. Simple","%",0,100,1,0,doNothing,noEvent,wrapStyle)//normal numeric field (1 edit level)
  ,altFIELD(cancelField,test,"Cancelable","%",0,100,10,1,doNothing,enterEvent,wrapStyle)//cancelable field (2 edit levels)
  ,altFIELD(cancelField,test,"C. Simple","%",0,100,1,0,doNothing,enterEvent,wrapStyle)//cancelable field (1 edit level)
  ,OBJ(option0)
  ,EDIT("Hex",buf2,validData,doNothing,noEvent,noStyle)
  ,EDIT("Name",name,alphaNum,doNothing,noEvent,noStyle)
  ,SUBMENU(subMenu)
  ,SUBMENU(setLed)
  ,OP("LED On",myLedOn,enterEvent)
  ,OP("LED Off",myLedOff,enterEvent)
  ,SUBMENU(selMenu)
  ,SUBMENU(chooseMenu)
  ,OP("Alert test",doAlert,enterEvent)
  ,EDIT("Hex",buf1,hexNr,doNothing,noEvent,noStyle)
  ,EXIT("<Back")
);

When this runs, Op1 is selectable (with the icon ">") but when I navigate to Op2 it seems disabled (with the icon "-"). As a test, I tried switching their position (so Op2 is top and Op1 is the second item in the menu) in which case Op1 (the second item in the menu) is disabled and Op2 (the first item in the menu) is now enabled. This behavior is unexpected, so I'm wondering if this is a bug or if there is something simple that I'm missing.

Please advise... Thank you.

neu-rah commented 4 years ago

Hi!

Second option is disabled programmatically and by index (not by definition), therefor no matter what option is on that place it will be disabled.

Its a demo of enabling / disabling options, cause by this line (or similar) on setup function

mainMenu[1].enabled=disabledStatus;

you're welcome.

grandlizardofthecanyons commented 4 years ago

thank you!