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

Draggable Windows?

Started by ObloxCC, 04 January 2017 - 08:30 PM
ObloxCC #1
Posted 04 January 2017 - 09:30 PM
Anyone know a easy way to created draggable windows that can run along side other independently draggable windows?
Bomb Bloke #2
Posted 05 January 2017 - 12:16 AM
This is the sort of question where if you have to ask, then you should probably be coding something else.

Exactly which part of the above are you getting stuck on? Processing mouse input? Updating the display? Running multiple co-routines side by side?
Exerro #3
Posted 05 January 2017 - 06:37 PM
Bomb Bloke covered the 3 main areas.

Processing mouse input: mouse events should be made relative to the window. That's pretty easy, just subtract the window coordinates and then add 1 (if you click on the top left of a window, those coords minus the window coords will be (0, 0), hence the +1 to make it (1, 1)).

Updating the display/rendering: there will be multiple windows, and they'll be 'layered' on top of each other, so you'll want to store that order somehow. Personally, I'd just use the order of the list of windows, and move a window to the end of the list when it's focused.

This is probably for an OS, so it's probably multitasking, and each window will be running separate programs, so you'll need a coroutine manager. Coroutines are CCs solution to multitasking, allowing multiple programs to be run in parallel… kinda. There are a few coroutine tutorials on the forums and elsewhere online.

Before you spend hours on this, I'd recommend you reconsider using windowing. CC screens are very small, and with just the window bar you'll be using 1/19th of the maximum possible space. There are much better ways of handling multitasking in my opinion.
ObloxCC #4
Posted 05 January 2017 - 08:12 PM
Bomb Bloke covered the 3 main areas.

Processing mouse input: mouse events should be made relative to the window. That's pretty easy, just subtract the window coordinates and then add 1 (if you click on the top left of a window, those coords minus the window coords will be (0, 0), hence the +1 to make it (1, 1)).

Updating the display/rendering: there will be multiple windows, and they'll be 'layered' on top of each other, so you'll want to store that order somehow. Personally, I'd just use the order of the list of windows, and move a window to the end of the list when it's focused.

This is probably for an OS, so it's probably multitasking, and each window will be running separate programs, so you'll need a coroutine manager. Coroutines are CCs solution to multitasking, allowing multiple programs to be run in parallel… kinda. There are a few coroutine tutorials on the forums and elsewhere online.

Before you spend hours on this, I'd recommend you reconsider using windowing. CC screens are very small, and with just the window bar you'll be using 1/19th of the maximum possible space. There are much better ways of handling multitasking in my opinion.

I was able to get the windows draggable with the help of tables.

If a mod is reading this the post can be locked
Lupus590 #5
Posted 05 January 2017 - 09:08 PM
If a mod is reading this the post can be locked
they don't like locking ask a pro posts as others may have similar issues need to ask for more information
Bomb Bloke #6
Posted 06 January 2017 - 12:08 AM
If you have other questions concerning this project, it'd be best for you to keep on using the one thread.