Create a hotspot area of a window?

Hi,
is it possible to check if the mouse is clicked anywhere below 50 pixels from the top of an empty window - thus causing an action to execute (such as displaying a MsgBox?)

I have found Window.MouseY in the Language reference, but there is no example and I doubt it is as simple as:

If Window1.MouseY > 50 then MsgBox("it worked") end if

I can’t even actually test it as I am away and only have my iPad available, and I do not want to waste the whole day by not learning anything :frowning:

If someone could advise me - it would be much appreciated.
Thank you all in advance.

You’d put code in the window’s MouseUp event and check it’s X and Y parameters. That code should look something like this:

  if X >= 0 and X < self.Width and Y > 50 and Y < self.Height then
    // The right area was clicked
  end if

You also have to return True in MouseDown just so MouseUp will fire.

Thank you very much Kem,
It is nice to know that there are still members on this forum who are not condescending to part time users such as myself.

I really appreciate it.

Thank You.

Richard, just a note that is sort of relevant. If you use the mouse up on a control e.g. image view and you have lock left, right set then the x / y info does not work correctly. I have logged in Feedback and it has been verified.

<https://xojo.com/issue/33275>

Thanks Nathan - I will bear that in mind :slight_smile: