OnMouseUp to work whenever mouse is on top.

Feature requests for future versions can be voiced here
Post Reply
Bugala
Posts: 1181
Joined: Sun Feb 14, 2010 7:11 pm

OnMouseUp to work whenever mouse is on top.

Post by Bugala »

Here is a test program to notice the problem and reason for wish:

Code: Select all

MakeButton(1, #SIMPLEBUTTON, 100, 100, 100, 100, {OnMouseUp=Function() TestText = "A" EndFunction})
MakeButton(2, #SIMPLEBUTTON, 300, 100, 100, 100, {OnMouseUp=Function() TestText = "B" EndFunction})
	
SetInterval(1, Function()
			Cls(0)
			Box(100, 100, 100, 100, #WHITE)
			Box(300, 100, 100, 100, #RED)
			TextOut(200, 300, TestText, #WHITE)
		        Flip()
		EndFunction, 25)
TestText="C"

BeginDoubleBuffer()
	
Repeat
	WaitEvent()
Forever
If you go on top of these boxes and LEFT CLICK mouse normally, you can notice how the letter changes.

But, if you move your mousepointer outside of the box, then push LEFT MOUSE down outside of the box, then move it on top of the button, and then release it for "OnMouseUp" to happen, then it doesn't react.

For "OnMouseUp"-event to trigger, mouse has to be above the button the whole time, from MOUSE DOWN, to MOUSE UP, or "OnMouseUp" wont trigger.

This is first of all unintuitive. Why name "OnMouseUp" when it doesn't actually mean it.

But more importantly, this is right now a problem for me which might need me make a lot of extra code, for what I was wishing to do was that since I have these "Rooms" in my editor, I was wanting to connect them together by simply pushing LEFT MOUSE DOWN on top of ROOM A, and then while keeping MOUSE DOWN, drag pointer above ROOM B and RELEASE the LEFT MOUSE BUTTON, and this way trigger "OnMouseUp" and tell they are now connected together.

However, since this behavior does not trigger "OnMouseUp" on ROOM B-button, I obviously cannot do it the simple way I meant, but now have to make code to figure out if it is above the other button or not.

Therefore a wish: Make "OnMouseUp" actually trigger when it is done above the button, no matter how it got there.

And second wish: Do make another "OnMouseUp" that works the way it currently does, it can be useful in some cases too.
Flinx
Posts: 192
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: OnMouseUp to work whenever mouse is on top.

Post by Flinx »

Bugala wrote: Tue Feb 13, 2024 3:13 pm Therefore a wish: Make "OnMouseUp" actually trigger when it is done above the button, no matter how it got there.
This would break a lot of Hollywood programs. At best, a new function would be acceptable.
But I'm answering because I don't like the example. You delete and draw with 40Hz boxes and output text, even if nothing changes. I don't think that's a good style. I hope it doesn't look the same in your program.
Bugala
Posts: 1181
Joined: Sun Feb 14, 2010 7:11 pm

Re: OnMouseUp to work whenever mouse is on top.

Post by Bugala »

Most of time I use something like this, since by default, something is always changing. Although that 40 hz was just a number I threw in this case to have some number there.

I could have used something else in this case instead, but since I by default intend to use it only myself, as long as it works on my machine, it doesn't have to work anywhere else, and since this way I can reuse my code, therefore doing it this way.

It depends upon program whether it is easier (from programming point of view) to redraw everything each cycle or just what has changed, they both have benefits, have tried both and most of time in my own programs it seems drawing everything each cycle has been the better option.
Post Reply