linking GUI
BlitzPlus Forums/BlitzPlus Programming/linking GUI
| ||
| hi all, im making some gui functions, its all going well so far but i was wondering what the best way to make say a button that when pressed returned the position of a list or a scroller that when moved, moved a list... thanks alot |
| ||
| You maybe interested in BlitzPlus rather than create your own GUI because PlitzPlus contains all these sorts of gadgets built it. Download the free demo and have alook at the samples. Alternatively, there are numerous GUI routines floating around at www.blitzcoder.com Regards |
| ||
Your best way to do is like so:
Type Button
field x,y,width,height
End type
Clicked.Button = null
repeat
for b.Button = eahc Button
if mousehit(1)=true and rectsoverlap(mousex(),mousey(),1,1,b\x,b\y,b\width,b\height)=true then
Clicked.Button = B.Button
exit
else
Clicked.Button = null
end if
next
if Clicked.Button <> null then
print Clicked\X+" "+Clicked\Y
end if
forever
|
| ||
| skn: mousehit(1) will only return TRUE once per mouse click so your code won't work unless the user clicks on the first button. You'll need to do something like: if mousehit(1) then for b.button = each button etc. |
| ||
I usually say, at the beginning of every loop:MouseClick = MouseHit(1) MouseUp = (MouseDn=1) And (MouseDown(1)=0) MouseDn = MouseDown(1) MXspd = MouseXSpeed() MYspd = MouseYSpeed() MZspd = MouseZSpeed() That usually takes care of everything. It would of course need to be modified if you want to take into account right-clicks. (MouseHit(2)) |