Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ############################################################
- function drag()
- while true do
- event, button, X, Y = os.pullEvent("mouse_drag") -- ### mouse drag function
- XY = X..","..Y
- -- ############################################################
- if button == 1 then -- window design
- term.setBackgroundColor(8)
- shell.run("clear")
- term.setBackgroundColor(8)
- term.setCursorPos(X-8,Y)
- term.setBackgroundColor(2048)
- write("Test ")
- term.setBackgroundColor(1)
- term.setBackgroundColor(16384)
- write("X") -- close (does not work) ####
- term.setBackgroundColor(256)
- term.setCursorPos(X-8,Y+1)
- print(" ")
- term.setCursorPos(X-8,Y+2)
- print(" Hello ")
- term.setCursorPos(X-8,Y+3)
- print(" ")
- term.setCursorPos(X-8,Y+4)
- print(" %")
- end
- end
- end
- -- ############################################################
- function click()
- while true do
- event, button, X, Y = os.pullEvent("mouse_drag") -- ### mouse drag function
- XY = X..","..Y
- event, button, X2, Y2 = os.pullEvent("mouse_click") -- click (close) function
- XY2 = X2..","..Y2
- if XY2 == (X + 8) .. "," .. Y and button == 1 then -- #### Close position
- shell.run("clear")
- print("Restart..")
- sleep(1)
- end
- end
- end
- -- ###########################Start#################################
- term.setBackgroundColor(8)
- shell.run("clear")
- print("Drag the mouse..\n# ----drag---> #")
- parallel.waitForAny(drag, click)
Add Comment
Please, Sign In to add comment