Mouse Button down to "scroll" some values (not clear enough sorry !)

Started by Baguettator, Sun 13/08/2023 22:04:36

Previous topic - Next topic

Baguettator

Hi here !

What I want to do is to be able to :

- click on a GUIButton, and let the mouse button (left) down
- while the mouse button is down, I move the mouse down to decrease some value, and move up to increase some value
- in facts, the "value" is the angle of the sprite of the GUIButton.
- in other words, I want to do something similar to, let's say, changing the angle of an image in "Photoshop" : you select the image, then you click and hold the mouse button down on a square near the image,, and by moving the mouse up or down, you rotate the image to your taste.

I don't really know how to do this in the easiest way in AGS, I can imagine that I have to store the mouse.X and mouse.Y coordinates when I click the button and then in the repeatedly execute I look at if I'm moving up or down from there, and so I change the angle. But I think it's not the easiest way, and perhaps it's not THAT way that I can do it, so... I'm here to gather your suggestions/solutions :)

Thank you all for all the help I found here since several years learning coding !

Crimson Wizard

Quote from: Baguettator on Sun 13/08/2023 22:04:36I don't really know how to do this in the easiest way in AGS, I can imagine that I have to store the mouse.X and mouse.Y coordinates when I click the button and then in the repeatedly execute I look at if I'm moving up or down from there, and so I change the angle

That's the only way, at least at the moment. Some engine may let you know the mouse's delta movement per frame, but AGS does not provide that.

Baguettator

OK I see !

The problem could be that the engine doesn't recognize the click if the button is kept down. If I click and keep the button down, it's not a click until I leave it. Is it an AGS limitation ?

Crimson Wizard

Quote from: Baguettator on Mon 14/08/2023 05:35:18The problem could be that the engine doesn't recognize the click if the button is kept down. If I click and keep the button down, it's not a click until I leave it. Is it an AGS limitation ?

This is not a limitation, this is a intended behavior: the button only considered "clicked" when you release a mouse on it. It works similar to how many other gui frameworks work. For example, this is a standard behavior in Windows applications.

The solution is to ignore the button's click event, and check for Mouse.IsButtonDown in repeatedly_execute instead.

Snarky

Quote from: Crimson Wizard on Mon 14/08/2023 06:47:07This is not a limitation, this is a intended behavior: the button only considered "clicked" when you release a mouse on it. It works similar to how many other gui frameworks work. For example, this is a standard behavior in Windows applications.

Though most other UI frameworks then also provide Control.OnMouseButtonDown and Control.OnMouseButtonUp events.

BTW, could your Drag-and-Drop module help in this situation?

Baguettator

OK, but How can I tell AGS that "I'm keeping the Mouse button down, so I want to do something, BUT I don't want to execute the script attached to a on_mouse_click" ?

The thing is I rotate a Gui Button by keeping the right mouse button down, but there is a script attached to this Button that is "if you right-click on it, it will rotate it by 45°". The problem is that rotating the button while right button is down works perfectly, but when I release it, the button is rotated by 45° because it's like a right mouse click...

Khris

Store the initial mouse coordinates when the button is held down. When the button is released, compare the current coordinates to the stored ones and only process it as click if they're the same.

eri0o

Operating on release is also expected in the Xbox Accessibility Guidelines, I recently noticed that this is how all operating systems works - on release, and they have an additional feature that if you release elsewhere you can cancel the action.

SMF spam blocked by CleanTalk