CC: Tweaked

CC: Tweaked

42M Downloads

better window API for CraftOs

gameplays12303 opened this issue ยท 4 comments

commented

i have been having some trouble with getting the absolute position of a window
i have added some code to the window.get-position
i was wondering if this may do
this
--- Get the absolute position of the top left corner of this window. function window.get_ABS_Position() local nX2,nY2 = 1,1 if parent.get_ABS_Position then nX2,nY2 = parent.get_ABS_Position() end return nX+nX2-1,nY+nY2-1 end
i have done test to this code and it dose not break backwards capability so long as you don't revert the modifcations you made to the multi shell

this file is the window ready for use just drop and replace but if need be you can test my own code
window.zip

commented

Hrmr. I'm not sure I think this is a good idea. There's no way to guarantee that you'll get the correct absolute position here, as non-window terminal redirects won't implement get_ABS_Position.

What contexts do you think this will be useful?

commented

this is meant to help sink up the os.pull Event, "mouse_click" and "monitor touch" so you can easily get the position of the window when a window is located inside a window

yes your correct it isn't the actual Absolute position but it doesn't need to be
as long as you don't remove this
-- Restrict the public view of the window to normal redirect functions. tProcess.terminal = {} for k in pairs(term.native()) do tProcess.terminal[k] = tProcess.window[k] end
from the multi shell it will work as expected

trust me the code works as intended so long as you don't remove that code
tested it myself and found no bugs (as of right now)

this code is to help develop button APIs

commented

If you need more clarification
i will link a video as this is hard to explain by text

commented

yes your correct it isn't the actual Absolute position but it doesn't need to be

this is meant to help sink up the os.pullEvent, "mouse_click" and "monitor touch" so you can easily get the position of the window when a window is located inside a window

I think you're touching on this already, but in these sorts of cases, you don't actually want the absolute position of the window. You want the position relative to some particular frame of reference.

I don't think there's a good way to do this automatically - for instance, your proposed implementation will break on other multishell like programs which don't hide their internals. Honestly, I think you're better off handling this in your own code - I haven't seen your whole program, but I suspect there's a way to restructure it that doesn't need this at all.