How does mouse detect?? [With VGA too]
I am writing a code for a device that involves a mouse, graphics, and tv driver. I have everything figured out exept how to click on a filled box with text in it; much like that on this computer. Here is the part of my code that hadles the visual and mouse:
· repeat
··· gr.clear
··· tvmessage2(20,172,80,20,@m1)
··· tvmessage2(20,150,80,20,@m2)
··· tvmessage2(20,128,80,20,@m3)
··· tvmessage2(20,106,80,20,@m4)
··· tvmessage2(20,84,80,20,@m5)
··· mousex := mousex + mouse.delta_x #> 0 <# SCREEN_WIDTH
··· mousey := mousey + mouse.delta_y #> 0 <# SCREEN_HEIGHT
··· gr.colorwidth(1,0)
··· gr.pix(mousex, mousey, 0, @pointer)
·····
··· gr.copy(onscreen_buffer)
The "tvmessage2" is a PRI routine I have written that allows you to plot a box anywhere at any size and the text still be centered in the middle. That aside, this will plot 5 text boxes and a mouse pointer(it looks like a computer pointer) that will move with the mouse delta. I want you to be able to click on a box(anywhere in the box) and it go to·another screen layout. I cannot figure out how to do this!
Please Help!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontroled.
If it's not Parallax then don't even bother. :-)
Propeller SRAM TV driver winner: ==NOT COMPLEATED:·1 1/2·WEEKS UNTIL ENDING TIME==
Post Edited (microcontrolled) : 6/22/2009 8:31:46 PM GMT
· repeat
··· gr.clear
··· tvmessage2(20,172,80,20,@m1)
··· tvmessage2(20,150,80,20,@m2)
··· tvmessage2(20,128,80,20,@m3)
··· tvmessage2(20,106,80,20,@m4)
··· tvmessage2(20,84,80,20,@m5)
··· mousex := mousex + mouse.delta_x #> 0 <# SCREEN_WIDTH
··· mousey := mousey + mouse.delta_y #> 0 <# SCREEN_HEIGHT
··· gr.colorwidth(1,0)
··· gr.pix(mousex, mousey, 0, @pointer)
·····
··· gr.copy(onscreen_buffer)
The "tvmessage2" is a PRI routine I have written that allows you to plot a box anywhere at any size and the text still be centered in the middle. That aside, this will plot 5 text boxes and a mouse pointer(it looks like a computer pointer) that will move with the mouse delta. I want you to be able to click on a box(anywhere in the box) and it go to·another screen layout. I cannot figure out how to do this!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontroled.
If it's not Parallax then don't even bother. :-)
Propeller SRAM TV driver winner: ==NOT COMPLEATED:·1 1/2·WEEKS UNTIL ENDING TIME==
Post Edited (microcontrolled) : 6/22/2009 8:31:46 PM GMT
Comments
Typically you check to see if the mouse pointer is within an imaginary box superimposed over the area you want to click.· I say imaginary, because it could be confined to anywhere on the screen.· At the same time you check if the mouse button is pressed or not.
Say for instance that the box takes up a 10x10 pixel square·with an upper right coordinate of· 15,15
mock code:
X = 15·· ' Box X coordinate
Y = 15·· ' Box Y coordinate
Xs = 10· ' Box X size
Ys = 10· ' Box Y size
Mx = MouseX
My = MouseY
Mb = MouseButton
If Mx·> X and Mx < X+Xs and My > Y and My·< Y+Ys and Mb = 1 then ... <- Mouse is over box and button1 is pressed if this is true
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
if mousex>20<100 and mousey>172<192 and mouse.button(1)==TRUE
tvmessage(@next)
else
return
When I run the program with this snippint of code in it the screen is blank. Does anyone know what I am doing wrong? I am a beginner at this sort of thing and I do not really know if this is not vailid Spin code. Please tell me how to put this in a good form. I'll keep trying!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank you for reading!·
···
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Thank you for reading!·
···
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Toys are microcontroled.
Robots are microcontroled.
I am microcontroled.
If it's not Parallax then don't even bother. :-)
Propeller SRAM TV driver winner: ==NOT COMPLEATED:·1 1/2·WEEKS UNTIL ENDING TIME==