-->
0 Members and 1 Guest are viewing this topic.
Screen = class() function Screen:init() end function Screen:paint(gc) endfunction Screen:timer() endfunction Screen:charIn(ch) endfunction Screen:arrowKey(key) endfunction Screen:escapeKey() endfunction Screen:enterKey() endfunction Screen:tabKey() endfunction Screen:contextMenu() endfunction Screen:backtabKey() endfunction Screen:backspaceKey() endfunction Screen:clearKey() endfunction Screen:mouseMove(x, y) endfunction Screen:mouseDown(x, y) endfunction Screen:mouseUp() endfunction Screen:rightMouseDown(x, y) endfunction Screen:help() end local Screens = {} function PushScreen(screen) table.insert(Screens, screen) platform.window:invalidate()end function PullScreen() if #Screens > 0 then table.remove(Screens) platform.window:invalidate() endend function activeScreen() return Screens[#Screens] and Screens[#Screens] or Screenend -- Link events to ScreenManagerfunction on.paint(gc) for _, screen in pairs(Screens) do screen:paint(gc) endend function on.timer() for _, screen in pairs(Screens) do screen:timer() endend function on.charIn(ch) activeScreen():charIn(ch) endfunction on.arrowKey(key) activeScreen():arrowKey(key) endfunction on.escapeKey() activeScreen():escapeKey() endfunction on.enterKey() activeScreen():enterKey() endfunction on.tabKey() activeScreen():tabKey() endfunction on.contextMenu() activeScreen():contextMenu() endfunction on.backtabKey() activeScreen():backtabKey() endfunction on.backspaceKey() activeScreen():backspaceKey() endfunction on.clearKey() activeScreen():clearKey() endfunction on.mouseDown(x, y) activeScreen():mouseDown(x, y) endfunction on.mouseUp() activeScreen():mouseUp() endfunction on.mouseMove(x, y) activeScreen():mouseMove(x, y) endfunction on.rightMouseDown(x, y) activeScreen():rightMouseDown(x, y) endfunction on.help() activeScreen():help() end function on.create() PushScreen(Menu()) endfunction on.resize() end
Screen = class() function Screen:init() end function Screen:paint(gc) endfunction Screen:timer() endfunction Screen:charIn(ch) endfunction Screen:arrowKey(key) endfunction Screen:escapeKey() endfunction Screen:enterKey() endfunction Screen:tabKey() endfunction Screen:contextMenu() endfunction Screen:backtabKey() endfunction Screen:backspaceKey() endfunction Screen:clearKey() endfunction Screen:mouseMove(x, y) endfunction Screen:mouseDown(x, y) endfunction Screen:mouseUp() endfunction Screen:rightMouseDown(x, y) endfunction Screen:help() end local Screens = {} function PushScreen(screen) table.insert(Screens, screen) platform.window:invalidate()end function PullScreen() if #Screens > 0 then table.remove(Screens) platform.window:invalidate() endend function activeScreen() return Screens[#Screens] and Screens[#Screens] or Screenend -- Link events to ScreenManagerfunction on.paint(gc) for _, screen in pairs(Screens) do screen:paint(gc) endend function on.timer() for _, screen in pairs(Screens) do screen:timer() endend function on.charIn(ch) activeScreen():charIn(ch) endfunction on.arrowKey(key) activeScreen():arrowKey(key) endfunction on.escapeKey() activeScreen():escapeKey() endfunction on.enterKey() activeScreen():enterKey() endfunction on.tabKey() activeScreen():tabKey() endfunction on.contextMenu() activeScreen():contextMenu() endfunction on.backtabKey() activeScreen():backtabKey() endfunction on.backspaceKey() activeScreen():backspaceKey() endfunction on.clearKey() activeScreen():clearKey() endfunction on.mouseDown(x, y) activeScreen():mouseDown(x, y) endfunction on.mouseUp() activeScreen():mouseUp() endfunction on.mouseMove(x, y) activeScreen():mouseMove(x, y) endfunction on.rightMouseDown(x, y) activeScreen():rightMouseDown(x, y) endfunction on.help() activeScreen():help() endfunction on.resize() endMenu = class(Screen)function Menu:init() print("your init code here")endfunction Menu:paint(gc) gc:drawString("Hello from the Menu Screen", 5, 5, "top")endPushScreen(Menu())
Thank you very much! And I can add other lines of text too, right?