Alright, so, what I have below is snippets of my code. Basically, they state that if the enter key is pressed, then to run the function related to the current selection, and that works fine. It also states that if the up or down arrow is pressed, the selection changes respectively on the menu, which also works. What I can't get to work, however, is a key to basically go back from a menu.

What I have is a main menu setup with an option that goes to another menu titled "Lights Menu". As of right now (for testing purposes), all it does is turn an output off or on when you press enter (depending on if it's the "lights on" or "lights off" option you have selected), and then set the variable that allows the Lights Menu to be displayed (Called inLightsMenu in the code below) to false, thus returning to the main menu.

I'm trying to basically set another key (backspace) to make the variable set to false. I won't be using it in this specific menu, but I wanted to test it so that I know how to do it for later when I actually want to use it.

It needs to basically be when the backspace key is pressed, AND inLightsMenu is true, then set inLightsMenu to false, which will return me to the main menu. Does anyone know how to make that work?

Thanks in advance!


function onKeyPressed( key, menu)
  if key == 28 then
	onItemSelected(menu)
  elseif key == 200 then
	if selectedItem > 1 then
	  selectedItem = selectedItem - 1
	end
  elseif key == 208 then
	if selectedItem < #menu then
	  selectedItem = selectedItem + 1
  elseif key == 14 and inLightsMenu == true then
	  inLightsMenu = false
	end
  end
end

EDIT: NEVERMIND. There appears to be no delete thread option here but oh well. It hit me just now with what was wrong. Here's how I fixed it if anyone ever comes into this thread with a similar question:


function onKeyPressed( key, menu)
  if key == 28 then
	onItemSelected(menu)
  elseif key == 200 then
	if selectedItem > 1 then
	  selectedItem = selectedItem - 1
	end
  elseif key == 208 then
	if selectedItem < #menu then
	  selectedItem = selectedItem + 1
   end                                                  -- This end needed to be here, instead of down there.
  elseif key == 14 and inLightsMenu == true then      
	  inLightsMenu = false
  end
end

I felt completely stupid after realizing this, apologies.