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.

Newcomers DBPro Corner / Clicking on an image without a pre-defined position

Author
Message
Veron
17
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 8th Jul 2007 09:31
I've searched everywhere, but haven't found anything to do with this problem.

Anyway, what i've got, is the user enters the X and Y position that they want the image (which they enter the filename of themselves) to be positioned. I've got that all working, no problems. But, when it comes to the user clicking on the image, how would that work? The X and Y image positions are stored in an array, and are loading fine. The code below is the code i'm using, but, when you click on the image, nothing happens. The mapsname$(1,3) array is definently working.



All help is appreciated.


[center]
Veron
17
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 8th Jul 2007 12:30
Hmm, you're right!

But, then, how would the code work at all?


[center]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Jul 2007 12:47 Edited at: 8th Jul 2007 12:48
Assuming Top = Element 1, Bottom = Element 2, Left = Element 3, Right = Element 4

IF Mx>=imgcoordx(1,3) AND My>=imgcoordy(1,1) AND Mx<=imgcoordx(1,4) AND My<=imgcoordy(1,2)

But this would be more efficient...



DBP always evaluates every part of the clause, even if the first one is false.

Veron
17
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 8th Jul 2007 15:30 Edited at: 9th Jul 2007 06:05
Interesting BatVink, i'll check that out in a sec, but, I was thinking the problem over myself, and I came up with two alternatives.

EDIT: Problem with yours though BatVink is, that when the user enters the co-ordinates for the image, they'd have to enter the TOP, LEFT, RIGHT and BOTTOM co-ordinates, which, if set to a different size than the image is, it'll change the image.

Alternative 1:

Hide the mouse cursor, then, load an image, and use that image as the cursor. (The image would be a standard cursor, so the end-user can't tell the difference)

Then, that cursor image is set to follow the position the mouse moves, so it functions exactly like the mouse. Then, you'd simply check to see, if the mouse is clicked while the cursor image is colliding with a button, execute the desired action.

Alternative 2:

Using the above code that I posted, but a modified version, like this:



Hope somebody understands what I mean there.

Problem is, DBP doesn't have a command which can find the size of a loaded image... or does it?

Opinions on which method would be more efficient (1,2 or BatVink's) are much appreciated.


[center]
Veron
17
Years of Service
User Offline
Joined: 22nd Nov 2006
Location:
Posted: 8th Jul 2007 17:32
Woah! Sorry man, somehow I totally missed your post!


[center]

Login to post a reply

Server time is: 2024-09-27 00:21:10
Your offset time is: 2024-09-27 00:21:10