How to manually release a mouse click + update the button's sprite

Started by Knox, Tue 12/04/2011 18:40:38

Previous topic - Next topic

Knox

If I click on a menu button, the button's sprite changes to the "pressed" sprite, like normal. However, I wrote a script that wont let the user hold down a button forever; after 20 game loops, Id like to "release" the button press, even if the mouse button is physically still held down by the player.

At the end of the while loop (when 20 loops are up), how can I manually release the mouse button (even if the player's finger is still holding down on it)...Im trying to force "mouse.IsButtonDown(eMouseLeft)"  to false myself, but I'm guessing its read-only?

If not, I guess at the end of the loop I could manually change the pressed button's graphic back to the normal graphic, but Id rather avoid that if possible...
--All that is necessary for evil to triumph is for good men to do nothing.

Khris

mouse.IsButtonDown() isn't just read-only, it's completely passive; even if you could set it to false, the hard-coded button behavior would still show the button's down image.

To achieve what you want you have to emulate the complete button behavior manually, I'm afraid.
In other words, change the images manually using GUIControl.GetAtScreenXY and mouse.IsButtonDown.

Another way maybe is to move the mouse off the button (mouse.SetPosition()), hide it and replace the visible mouse cursor with a GUI graphic that tricks the player into thinking it's the mouse.

On the other hand, a button's OnClick is only called as soon as the mouse button is released while the mouse cursor is still over the button i.e. holding down a GUI button does absolutely nothing. Why would the player do that in the first place?

Knox

Well its to make the whole UI homogenous...I dont know why a player would hold down the mouse button on a gui button...I guess I just wanted to make sure that if they did, it cant be held down for longer than 20 loops...i guess it doesnt matter, I just wanted that in there for personal preference, heh.

Ok, well if I have to do it the manual way, I think I might just forget it!
--All that is necessary for evil to triumph is for good men to do nothing.

Ryan Timothy B

Are you speaking of how clicking on a Character/Object/Hotspot interaction occurs the moment you press down on the mouse button, yet GUI buttons and inventory items interact the moment you release the mouse button?

If that's the case, if you're going to go through all the trouble of trying to make everything the same. Why not make it like Windows, how you can actually hold the mouse button over something, you then have the option of changing your mind by just moving the mouse before you release the button.

I've done the exact same thing with Journey of Iesir. I agree little touches like that make the UI much more sensible and the effort worthwhile.
I also have it where I can hold the mouse button on the screen, move it to the inventory bar and release it on an inventory item and it'll actually select the inventory item.

The only exception being dialog options. But I'm sure if I made a custom dialog GUI, I could probably do the same.

Knox

wow that's awesome Ryan...I agree aswell, I think its important little things like that. It shows if you give attention to small stuff like that, imagine what it will be for the bigger things! That's a good idea, perhaps I'll go the "windows" route aswell. :)

As for the custom dialog, abstauber's is pretty awesome...just need to tweek a few things (for homogeneity), but not there yet :P

--All that is necessary for evil to triumph is for good men to do nothing.

SMF spam blocked by CleanTalk