Hi. For some reason, it's not working again...
I can't get it to check for the right coordinates and allow clicking of the menu dependant on those coordinates.
it also is exploding the menus.
if you don't believe me, compile it and see.
here's the code:
Rem Project: rightclick1
Rem Created: Saturday, January 01, 2011
Rem ***** Main Source File *****
`%Project Title%
`%Source File Name%
`======================
sync on
global mousex#,mousey#
global mousex1#,mousey1#
global mousex2#,mousey2#
global mouseact#
global mouser#
global mouseg#
global mouseb#
global mx1
global my1
global txt$
gosub _mouseglobals
do
cls
mx1=mousex()
my1=mousey()
gosub _mousemenu
ink rgb(255,255,255),0
center text screen width()/2, screen height()/2, "menuselected:"+str$(menuselected)
center text screen width()/2, screen height()/2+20, "mouseact#:"+str$(mouseact#)
sync
loop
_mouseglobals:
global menuselected
` These variables are where the menu box begins
mousex1# = 0
mousey1# = 0
` These variables are where the menu box ends
mousex2# = 0
mousey2# = 0
mouseact# = 0
return
function call_rightmenu(menu)
select menu
case 1
end
endcase
case 2
end
endcase
case 3
end
endcase
endselect
endfunction
_mousemenu:
if mouseclick()=2
mousex2# = mousex#+100
mousey2# = mousey#+200
mousex# = mx1
mousey# = my1
mouseact# = 1
endif
if mouseact#=0 and menuselected>0 and mouseclick()=1
end
endif
if mouseact#=1 and mouseclick()=1
mouseact#=0
offsetx1=25
offsetx2=65
offsety1=10
if mx1>text width(txt$) and my1 > mousey#+offsety and mx1 < mousex#+offsetx2 and my1<mousey#+offsetx1 then call_rightmenu(1)
offsetx1=30
offsetx2=65
offsety1=30
if mx1>text width(txt$) and my1 > mousey#+offsety and mx1 < mousex#+offsetx2 and my1<mousey#+offsetx1 then call_rightmenu(2)
offsetx1=5
offsetx2=65
offsety1=50
if mx1>text width(txt$) and my1 > mousey#+offsety and mx1 < mousex#+offsetx2 and my1<mousey#+offsetx1 then call_rightmenu(3)
remstart
offsetx1=30
`File Coords
if mx1 > mousex#+offsetx1 and my1 > mousey#+10 and mx1 < mousex#+65 and my1 < mousey#+25 then call_rightmenu(1)
`Copy Coords
if mx1 > mousex#+30 and my1 > mousey#+30 and mx1 < mousex#+65 and my1 < mousey#+45 then call_rightmenu(2)
`Something Coords
if mx1 > mousex#+5 and my1 > mousey#+50 and mx1 < mousex#+98 and my1 < mousey#+65 then call_rightmenu(3)
remend
endif
if mouseact#=1
`If the user clicks outside of the box then the menu hides
` if mousex() > mousex# and mousey() > mousey# and mousex() < mousex2# and mousey() < mousey2# and mouseclick()=1
` if mouseclick() = 1: act# = 0: endif
` endif
`This makes the menu come into view and makes the selected option turn red behind
// draw window
box mousex#,mousey#,text width(txt$),mousey2#,rgb(0,255,128),rgb(0,128,64),rgb(0,64,32),rgb(0,32,0)
// draw buttons
get_menu(10,10,"Open Level",255,255,255)
get_menu(10,30,"Save Level",255,255,255)
get_menu(10,50,"View Object Info",255,255,255)
get_menu(10,70,"TestTestTestTestTestTestTestTestTestTestTestTestTestTestTest",255,255,255)
remstart
`The copy option
ink rgb(mouser2#,mouseg2#,mouseb2#)
box mousex#+30,mousey#+30,mousex#+65,mousey#+45
ink rgb(0,0,0)
if mx1 > mousex#+30 and my1 > mousey#+30 and mx1 < mousex#+65 and my1 < mousey#+45: mouser2# = 225: mouseg2# = 0: mouseb2# = 0: else: mouser2# = 225: mouseg2# = 225: mouseb2# = 220: endif
text mousex#+30,mousey#+30,"Copy Object"
`The paste option
ink rgb(mouser3#,mouseg3#,mouseb3#)
box mousex#+5,mousey#+50,mousex#+98,mousey#+65
ink rgb(0,0,0)
if mx1 > mousex#+5 and my1 > mousey#+50 and mx1 < mousex#+98 and my1 < mousey#+65: mouser3# = 225: mouseg3# = 0: mouseb3# = 0: else: mouser3# = 225: mouseg3# = 225: mouseb3# = 220: endif
text mousex#+5,mousey#+50, "Paste Object"
`The delete option
ink rgb(mouser2#,mouseg2#,mouseb2#)
box mousex#+30,mousey#+30,mousex#+65,mousey#+45
ink rgb(0,0,0)
if mx1 > mousex#+30 and my1 > mousey#+30 and mx1 < mousex#+65 and my1 < mousey#+45: mouser2# = 225: mouseg2# = 0: mouseb2# = 0: else: mouser2# = 225: mouseg2# = 225: mouseb2# = 220: endif
text mousex#+30,mousey#+30,"Delete Object"
remend
endif
return
function get_menu(x,y,txt$,mouser as byte,mouseg as byte,mouseb as byte)
if txt$ = "" then exitfunction
xlength = text width(txt$)
ylength = text height(txt$)
ink rgb(mouser,mouseg,mouseb)
if mx1 > mousex#+x and my1 > mousey#+y and mx1 < (mousex#+x)+xlength and my1 < (mousey#+y)+ylength
mouser = 255: mouseg = 0: mouseb = 0
else
mouser = 225: mouseg = 225: mouseb = 220
endif
//draw button background
ink rgb(128,128,128)
box mousex#+x,mousey#+y,mousex#+xlength,(mousey#+y)+ylength
//draw button text
ink rgb(mouser,mouseg,mouseb)
text mousex#+x,mousey#+y,txt$
endfunction
Thank you for the help!
Feel free to use it as a token of my gratitude
CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!