Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Window Border Detection for Pen OS
- TeenySpoon
- Scratcher
500+ posts
Window Border Detection for Pen OS
Hello, I've been working on a Pen OS on my alt.
I'm doing the window manager and trying to detect when the mouse is touching the borders of the window.
Unfortunately, it only detects the left and right borders and not the top and bottom.
Link: https://scratch.mit.edu/projects/874089841/editor/
See the “Input Check ()” custom block, where it says “borders”
I think that the problem has to do with the numbers I'm using for the y axis.
Other things:
Thanks!
I'm doing the window manager and trying to detect when the mouse is touching the borders of the window.
Unfortunately, it only detects the left and right borders and not the top and bottom.
Link: https://scratch.mit.edu/projects/874089841/editor/
See the “Input Check ()” custom block, where it says “borders”
I think that the problem has to do with the numbers I'm using for the y axis.
Other things:
- Mouse properties list is set up like this: 1.) cursor icon 2.) window ID that it is hovering on 3.) portion of the window (app, header, and border) 4.) details (e.g. button)
- Pen size used for the window is 10 pixels
- Window headers are 30 pixels tall
Thanks!
⚜ TeenySpoon ⚜ Alt: TeenyTea ⚜
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
- Zurdax
- Scratcher
100+ posts
Window Border Detection for Pen OS
Found the mistake! Its actually quite easy to spot.
You simply forgot to add the if else block for asking if y is true.
So not like this:
You simply forgot to add the if else block for asking if y is true.
So not like this:
if <[input X] = [true]> thenBut like this:
if <[input Y] = [true]> then
...
else
...
end
else
...
end
if <[input X] = [true]> then
if <[input Y] = [true]> then
...
else
...
end
else
if <[input Y] = [true]> then
...
else
...
end
Last edited by Zurdax (July 19, 2023 20:35:26)
play note (58 v) for (1) beatsYou know who this is? Really love his choir music!
play note (57 v) for (1) beats
play note (60 v) for (1) beats
play note (59 v) for (1) beats
Also check out my first program: https://scratch.mit.edu/projects/767390216/
- TeenySpoon
- Scratcher
500+ posts
Window Border Detection for Pen OS
Which part is this? Found the mistake! Its actually quite easy to spot.
You simply forgot to add the if else block for asking if y is true.
I have several nested if-else blocks in that one custom block.
⚜ TeenySpoon ⚜ Alt: TeenyTea ⚜
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
- Zurdax
- Scratcher
100+ posts
Window Border Detection for Pen OS
The part which is for setting the “boarder” thing. You have a comment on that part with “boarder”.
Last edited by Zurdax (July 19, 2023 20:40:16)
play note (58 v) for (1) beatsYou know who this is? Really love his choir music!
play note (57 v) for (1) beats
play note (60 v) for (1) beats
play note (59 v) for (1) beats
Also check out my first program: https://scratch.mit.edu/projects/767390216/
- TeenySpoon
- Scratcher
500+ posts
Window Border Detection for Pen OS
I just wanted to make sure. The part which is for setting the “boarder” thing. You have a comment on that part with “boarder”.
Why would I need an if block for y in the “else” portion?
I only need something to run if both x and y are true.
⚜ TeenySpoon ⚜ Alt: TeenyTea ⚜
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
- Zurdax
- Scratcher
100+ posts
Window Border Detection for Pen OS
Because if its not true for X then it isn't even asking if its true for y.
play note (58 v) for (1) beatsYou know who this is? Really love his choir music!
play note (57 v) for (1) beats
play note (60 v) for (1) beats
play note (59 v) for (1) beats
Also check out my first program: https://scratch.mit.edu/projects/767390216/
- TeenySpoon
- Scratcher
500+ posts
Window Border Detection for Pen OS
Yes, because if it's not true for X it doesn't need to run. It needs to be true for both. Because if its not true for X then it isn't even asking if its true for y.
I only split them up for efficiency, so that the code will stop checking y if x isn't true.
Last edited by TeenySpoon (July 19, 2023 20:44:35)
⚜ TeenySpoon ⚜ Alt: TeenyTea ⚜
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
- Zurdax
- Scratcher
100+ posts
Window Border Detection for Pen OS
There are 4 possibilities:
1. Its on the x-Boarder
2. Its on the x- and y-Boarder
3. Its on no boarder
4. Its on the y-boarder
You have only asked for those first 3 possibilities in your code.
1. Its on the x-Boarder
2. Its on the x- and y-Boarder
3. Its on no boarder
4. Its on the y-boarder
You have only asked for those first 3 possibilities in your code.
play note (58 v) for (1) beatsYou know who this is? Really love his choir music!
play note (57 v) for (1) beats
play note (60 v) for (1) beats
play note (59 v) for (1) beats
Also check out my first program: https://scratch.mit.edu/projects/767390216/
- Zurdax
- Scratcher
100+ posts
Window Border Detection for Pen OS
What if its only on the y? Than X will not be true -> triggering the false part of the code. But if X isn't true Y can still be.
play note (58 v) for (1) beatsYou know who this is? Really love his choir music!
play note (57 v) for (1) beats
play note (60 v) for (1) beats
play note (59 v) for (1) beats
Also check out my first program: https://scratch.mit.edu/projects/767390216/
- TeenySpoon
- Scratcher
500+ posts
Window Border Detection for Pen OS
I see what you mean now. There are 4 possibilities:
1. Its on the x-Boarder
2. Its on the x- and y-Boarder
3. Its on no boarder
4. Its on the y-boarder
You have only asked for those first 3 possibilities in your code.
However, my code isn't checking for the specific border yet.
First, it checks for if it is within the window x. Then it checks the y. If it is within those, it is in the app portion. if it is in the x but not the y, it shifts the y check upwards to check for the header.
If it is neither the header or the app, it expands the check outwards by a few pixels. So the check technically still contains the app and header portion, but because the previous check was false it should only work for the border.
My problem is that it works for the left and right borders but not the top and bottom. If I'm still misunderstanding, could you please explain again?
Thanks
⚜ TeenySpoon ⚜ Alt: TeenyTea ⚜
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
- TeenySpoon
- Scratcher
500+ posts
Window Border Detection for Pen OS
That isn't supposed to happen with my current checks. It doesn't actually check the border, it checks in a square that contains the app, header, and border. However if the app and header was false the check should only work for the border. What if its only on the y? Than X will not be true -> triggering the false part of the code. But if X isn't true Y can still be.
⚜ TeenySpoon ⚜ Alt: TeenyTea ⚜
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
- Zurdax
- Scratcher
100+ posts
Window Border Detection for Pen OS
Ahh I'll need to look at the code a bit more. My solution just breaks things a bit. It actually fixes your problem but only for two windows and breaks some other things. Sorry, I was wrong.
play note (58 v) for (1) beatsYou know who this is? Really love his choir music!
play note (57 v) for (1) beats
play note (60 v) for (1) beats
play note (59 v) for (1) beats
Also check out my first program: https://scratch.mit.edu/projects/767390216/
- TeenySpoon
- Scratcher
500+ posts
Window Border Detection for Pen OS
Okay, thank you! Ahh I'll need to look at the code a bit more. My solution just breaks things a bit. It actually fixes your problem but only for two windows and breaks some other things. Sorry, I was wrong.
⚜ TeenySpoon ⚜ Alt: TeenyTea ⚜
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
- Zurdax
- Scratcher
100+ posts
Window Border Detection for Pen OS
Ok I think I kind of got the idea of your code now.
So you start off by asking if the cursor is inside the “app”-area for x.
If it is then it asks if its inside the “app”-area for y.
If its not then there are these possibilities listed:
1. Its the header
2. Its one of the options (minimalist, full screen, close
3. Its none
Here is where you have to ask for if its the boarder am I right? But that is missing.
So you start off by asking if the cursor is inside the “app”-area for x.
If it is then it asks if its inside the “app”-area for y.
If its not then there are these possibilities listed:
1. Its the header
2. Its one of the options (minimalist, full screen, close
3. Its none
Here is where you have to ask for if its the boarder am I right? But that is missing.
Last edited by Zurdax (July 19, 2023 21:12:10)
play note (58 v) for (1) beatsYou know who this is? Really love his choir music!
play note (57 v) for (1) beats
play note (60 v) for (1) beats
play note (59 v) for (1) beats
Also check out my first program: https://scratch.mit.edu/projects/767390216/
- TeenySpoon
- Scratcher
500+ posts
Window Border Detection for Pen OS
Yes, that is correct. Ok I think I kind of got the idea of your code now.
So you start off by asking if the cursor is inside the “app”-area for x.
If it is then it asks if its inside the “app”-area for y.
If its not then there are these possibilities listed:
1. Its the header
2. Its one of the options (minimalist, full screen, close
3. Its none
Here is where you have to ask for if its the boarder am I right? But that is missing.
The border part is at the bottom, in the else block. It's there because the above checks returned false, so it expands the check which should detect the borders.
I say should because it only detects some of them. I feel like it might be the numbers I used but I don't know.
Hold on, I have an idea. I'll try it and tell you if it worked
⚜ TeenySpoon ⚜ Alt: TeenyTea ⚜
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
⚜ An absent-minded programmer/artist ⚜
A Random Pen Window Manager
⚜ Me ⚜ TeenyFork ⚜ TeenyKnife ⚜
“We are pilgrims on the journey
We are travelers on the road
We are here to help each other
Walk the mile and bear the load”
- “The Servant Song”, David Haas
- Zurdax
- Scratcher
100+ posts
Window Border Detection for Pen OS
I remixed your project and was able to fix it… mostly because the bottom boarder of one window still can't be detected.
play note (58 v) for (1) beatsYou know who this is? Really love his choir music!
play note (57 v) for (1) beats
play note (60 v) for (1) beats
play note (59 v) for (1) beats
Also check out my first program: https://scratch.mit.edu/projects/767390216/
- Zurdax
- Scratcher
100+ posts
Window Border Detection for Pen OS
Nvmnd I fixed that bug too! Everything is working now.
play note (58 v) for (1) beatsYou know who this is? Really love his choir music!
play note (57 v) for (1) beats
play note (60 v) for (1) beats
play note (59 v) for (1) beats
Also check out my first program: https://scratch.mit.edu/projects/767390216/
- Discussion Forums
- » Help with Scripts
- » Window Border Detection for Pen OS