Sign in to follow this  
Followers 0
Champak

Problem with image and event

8 posts in this topic

My app is set up based on onevent functions. I have a problem with two solutions; solution one I can't get to work, solution two I don't know how to get it to work.

Solution 1:

I have two seporate images, a small one on top of another. The smaller one on the lower half of the larger one. The problem is, even though I set up guictrlonevent pointing to different functions on each of them, only the larger on in the background registers even when I press the smaller one on the lower half of the larger one....almost as if the press of the pic is going right through it to the larger on beneath.

Solution 2:

I was thinking of setting it up so I just use one pic it goes to one function, but if it is pressed withing a certain area...the lower half of the image...it does one thing, and something else if it is pressed somewhere else within the image. But I don't know how exactly to do this. I assume it has something to do with getting the mouse position, but as I see it, that would only give me the x,y position instead of a rectangular area.

Any help on either?

Thanks.

Share this post


Link to post
Share on other sites



This may not suit your purposes but if you know the image placement on your GUI just disable the images once they're drawn, get the x,y pos of the mouse, and do a bit of math to see where it is in relation to the images.

Share this post


Link to post
Share on other sites

That wouldn't work because disabling the larger image on the background disables its own function which is needed.

Share this post


Link to post
Share on other sites

(pseudo-code to place in the beginning of whatever functions run when the large image is clicked)

if "mouse-y-coordinate" > "smaller-image-y-position" then Return DoSomethingElse()

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

This may not suit your purposes but if you know the image placement on your GUI just disable the images once they're drawn, get the x,y pos of the mouse, and do a bit of math to see where it is in relation to the images.

If you disable the images you can still use the function like I suggested. If the mouse is on the portion of the larger image call that function and if it's on the smaller one call that function.

Edited by dbzfanatic

Share this post


Link to post
Share on other sites

@AdmiralAlkex thanks, you helped me rethink how I was thinking about the coordinates, this is what I came up with and it is working on my test script, just have to see if it works in the real one.

$this = MouseGetPos ()
    If $this[0] > 0 And $this[0] < 147 And $this[1] > 0 And $this[1] < 147 then
        MsgBox(0,0,0)
    Else
        MsgBox(0,1,1)
    EndIf

@dbzfanatic I see what you are saying now.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

@AdmiralAlkex thanks, you helped me rethink how I was thinking about the coordinates, this is what I came up with and it is working on my test script, just have to see if it works in the real one.

-snipped-

That was about the first time I used pseudo-code, I am glad you understood ;) I hope it is for some use to you!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0