Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Quick (and probably very easy) question

Author
Message
Lost In Code
22
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 10th Oct 2003 08:30
how the heck do I set up some sort of menu system to where I can use the mouse for selection.

I think what I realy want to know is this... say I have images set up as different menu items. How can I select these items with the mouse?

Thanks again for all your help.
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 10th Oct 2003 09:01
theres a few things you have to consider when doing this

imagine each image is 100 x 10 as an example

lets take a look at what we have so far

the top left corner is the first co ordinates

x1,y1

x2,y2

the bottom right hand corner is the other 2 co ordinates we need to know.

we can detect the mouse within this space since we know the area but if its no hard up on the top left corner of the screen it wont work because there is an offset of where the co ordinates start.

this in itself is not enough to detect if the mouse if over this area composed of 4 co ordinates unless we factor in the co ordinates of the offset position.

Lets say for simplicity the image is 100 x 100 offset from the top left hand corner of the screen

and lets manually add up each new x y co ordinate with the offset as well

so

x1 = 100
y1 = 100

x2 = 100 +100 = 200
y2 = 100 +10 = 110

so now we know it would be this result keeping in mind the area of the button and the offset position.


x1 = 100
y1 = 100
x2 = 200
y2 = 110



to write this in code we have to say

if the mouse position is greater then the first two and less then the last two and the mouse is clicked.


to write this into code we would use an if statement something similar to this

If mousex()>x1 and mousex()<x2 and mousey()>y1 and mousey()<y2 and mouseclick()=1
rem perform your button click action here
endif


naturally Ive assumed that the variables x1 x2 y1 y2 have been declared with the values prior to this. Also to make life easier you can visualise the hotspot area with the box command in testing by using the same variables to create a coloured box to see if the hot spot is working correctly before using your button media.

Codger
23
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 10th Oct 2003 10:09
Check out the Code (Sunk / Raised Command Buttons) I Posted in the Snippet Forum it may do what you need, or one of the addins for menus by Rob K.

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
Lost In Code
22
Years of Service
User Offline
Joined: 23rd Sep 2003
Location:
Posted: 11th Oct 2003 04:41
Thanks guys! Brilliant! I don't know why I didn't think of this but hey.

Thanks again!
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 11th Oct 2003 14:03
no worries mate
good luck

Login to post a reply

Server time is: 2026-07-26 05:02:43
Your offset time is: 2026-07-26 05:02:43