i am working on 2 programs at the minute and i am using the same mouse event function to draw menus and what not, one of the programs i have been foring on for over 6+ months and the mouse events worked fine but now it doesnt work propper.
INFO: when the "menu" secection is clicked, it should draw a drop down menu, however, it does do that but when i let go of the mouse button, the menu goes away, i have checked the code and cant see anything wrong with it unless im just not noticing the problem.
Here is the 2 peices of code:
function drawLogMenu()
term.setBackgroundColour(c_writing)
term.setTextColour(c_menu)
term.setCursorPos(33,2)
print("===================")
term.setTextColour(c_border)
term.setCursorPos(33,3)
print(" Reboot System ")
term.setCursorPos(33,4)
print(" ")
term.setCursorPos(33,5)
print(" Shutdown System ")
term.setCursorPos(33,6)
term.setTextColour(c_menu)
print("===================")
term.setCursorPos(43,1)
term.setTextColour(c_off)
term.setBackgroundColour(c_error)
print("System <<")
term.setBackgroundColour(black)
end
This one is the draw menu and this one:
function login3() ls = 0 logScreen = true while logScreen == true do local event, button, X, Y = os.pullEventRaw() if ls == 0 then if event == "mouse_click" then if X >=43 and X <=52 and Y == 1 and button == 1 then drawLogMenu() ls = 1 elseif X >=21 and X <=38 and Y == 8 and button == 1 then logScreen = false term.setCursorPos(21,8) elseif X >=20 and X <=33 and Y == 15 and button == 1 then logScreen = false accountCreation() elseif X >=38 and X <=51 and Y == 15 and button == 1 then logscreen = false accountDeletion() else login() end end elseif ls == 1 then if X >=35 and X <=50 and Y == 3 and button == 1 then ls = 0 rednet.send(ServerID, "systemReboot") os.reboot() elseif X >=34 and X <=51 and Y == 5 and button == 1 then ls = 0 os.shutdown() else ls = 0 login() end end end end
This one is the Mouse event code.
Any help would be muchly appreciated,
Thanks, MrProgrammer...
Edited by Mr_Programmer, 04 January 2016 - 12:43 AM.
- Indentation.












