This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
nikov2002's profile picture

Window with a running program

Started by nikov2002, 31 August 2015 - 04:09 PM
nikov2002 #1
Posted 31 August 2015 - 06:09 PM
I want to make a movable window using window.create (or something else) with an app running in it. Actually I have a code, that allows me to move pseudo-window, I will put the code down here. Is it possible ?


If you have an api, that allows me to do it, give me a link please :D/>


Code for moving, that is 'modified version' of laby os
Spoiler

-- ############################################################
plany = true
term.setCursorBlink(false)
os.loadAPI("windows")

function drag()
while true do
   event, button, X, Y, xSize, ySize = os.pullEvent("mouse_drag") -- ### mouse drag function
   XY = X..","..Y
  
  
-- ############################################################
	if button == 1 then -- window design
   windows.clearScreen(colors.lightBlue)
	  windows.square(X-8,Y,17,1,colors.lightGray)
	  windows.colorTextWithBack(X-8,Y,"X",colors.white,colors.red)
windows.square(X-8,Y+1,17,4,colors.white)
	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

  plany = false
os.reboot()
end

end
end
-- ###########################Start#################################
term.setBackgroundColor(colors.lightBlue)
shell.run("clear")
parallel.waitForAny(drag, click)





Please, don't look @ my grammar, because i'm russian
Edited on 31 August 2015 - 04:36 PM
Twijn #2
Posted 31 August 2015 - 09:47 PM
I want to make a movable window using window.create (or something else) with an app running in it. Actually I have a code, that allows me to move pseudo-window, I will put the code down here. Is it possible ?


If you have an api, that allows me to do it, give me a link please :D/>


Code for moving, that is 'modified version' of laby os
Spoiler

-- ############################################################
plany = true
term.setCursorBlink(false)
os.loadAPI("windows")

function drag()
while true do
   event, button, X, Y, xSize, ySize = os.pullEvent("mouse_drag") -- ### mouse drag function
   XY = X..","..Y
  
  
-- ############################################################
	if button == 1 then -- window design
   windows.clearScreen(colors.lightBlue)
	  windows.square(X-8,Y,17,1,colors.lightGray)
	  windows.colorTextWithBack(X-8,Y,"X",colors.white,colors.red)
windows.square(X-8,Y+1,17,4,colors.white)
	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

  plany = false
os.reboot()
end

end
end
-- ###########################Start#################################
term.setBackgroundColor(colors.lightBlue)
shell.run("clear")
parallel.waitForAny(drag, click)

You could possibly edit the method term.setCursorPos and term.getCursorPos and os.getSize to the size of the window, and make (1,1) be on the top left side of the window.
nikov2002 #3
Posted 01 September 2015 - 06:51 AM
I want to make a movable window using window.create (or something else) with an app running in it. Actually I have a code, that allows me to move pseudo-window, I will put the code down here. Is it possible ?


If you have an api, that allows me to do it, give me a link please :D/>


Code for moving, that is 'modified version' of laby os
Spoiler

-- ############################################################
plany = true
term.setCursorBlink(false)
os.loadAPI("windows")

function drag()
while true do
   event, button, X, Y, xSize, ySize = os.pullEvent("mouse_drag") -- ### mouse drag function
   XY = X..","..Y
  
  
-- ############################################################
	if button == 1 then -- window design
   windows.clearScreen(colors.lightBlue)
	  windows.square(X-8,Y,17,1,colors.lightGray)
	  windows.colorTextWithBack(X-8,Y,"X",colors.white,colors.red)
windows.square(X-8,Y+1,17,4,colors.white)
	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

  plany = false
os.reboot()
end

end
end
-- ###########################Start#################################
term.setBackgroundColor(colors.lightBlue)
shell.run("clear")
parallel.waitForAny(drag, click)

You could possibly edit the method term.setCursorPos and term.getCursorPos and os.getSize to the size of the window, and make (1,1) be on the top left side of the window.

Actually, I have two variables, on which all the drawing code is working, I' ll try to make term.getSize() to be on top of.. you know
Variables are xSize, ySize