[Solved]GUI and button handling

Started by NickyNyce, Thu 29/12/2011 20:29:46

Previous topic - Next topic

NickyNyce

Hello everyone,

I'm currently digging into GUI's and buttons, they're easy to make and things seem to be moving along well with the help of the manual. I made a GUI with 5 buttons that is pretty small, the GUI only covers a small portion of the screen, so a lot of the room is still visible. I'm trying to make it so the mouse cursor can only hover over the GUI and not the visible part of the room once the GUI opens, I don't want the player to be able to interact with anything but the GUI and buttons. I also noticed that after I press a button, I can no longer press it again. I think I fixed this by adding (return;) at the bottom of the buttons on click code. Is this the proper way to go about having the player be able to press these buttons multiple times?

Thanks in advance

RetroJay

This is finally something I can help with, I think.

You need to use something like this.
Code: ags

  mouse.SetBounds(1, 14, 108, 93);
}


This restricts the mouse to the area defined by the coordinates you specify.
Put this line withing the GUI's script and change the coords to what you want.

Then whatever button closes your GUI put this.
Code: ags

mouse.SetBounds(0,0,0,0);


This returns the mouse to original screen coverage.

As for the other question. If it works then leave well alone. ;)

Hope this helps.
Jay.

NickyNyce

#2
Thanks a bunch RetroJay, I have trouble finding these (setbounds) key words sometimes. I'm gonna give it a try, I'll edit soon if it solves my problem


EDIT: Thanks RetroJay, this should work fine

Khris

Quote from: NickyNyce on Thu 29/12/2011 20:29:46I also noticed that after I press a button, I can no longer press it again. I think I fixed this by adding (return;) at the bottom of the buttons on click code.

What exactly do you mean by that? Is the button disabled, greyed out? Or can you still visibly click it but nothing happens if you do?

Adding return; (why on earth would you put a single command in brackets, let alone round ones...?) at the bottom of a function doesn't change anything; the original purpose of the return command is to return a value; it can be "abused" to exit a function prematurely though. But like I said, if it's the last command inside a function, the outcome is exactly the same.

NickyNyce

#4
Hey Khris,

No no, sorry, that's just me not knowing any better how to type  :-[  I just had return; in blue

The buttons grey out after I press one of them which is fine, I have an object that changes view and animates on the click, and the buttons become available again when it's done.

For the love of god, I can't figure out why I needed to, or why I added return at the bottom of the code in the on click function, I could have sworn that after I pressed the GUI's button, (and seeing it move and get pressed) that I could not hit it a second time... ???

I added return at the bottom of the code and after that,  I could press it again. Please tell me I'm not going nuts, although I think your about to. I did remove it now, and things work fine, I can press the button more then once, so it seems that return was unneccesary now.

If I'm going crazy I apologize for wasting your time

RetroJay

#5
Khris (muc).

Sorry. I will always know you as 'Khris Muc' my mentor.

Jesus Christ.
Was I right about something?

Have a Happy New Year.

EDIT: NickyNyce. Glad I could help. Have a Happy New Year.
Jay.

Khris

Hey Jay,

sure, your post was perfectly fine, I was just asking NickyNyce for some specifics about his second question.

Happy New Year to you, too!


NickyNyce:
Maybe you've changed something else, too? All I can say is that what you did shouldn't have changed anything; in fact I'm certain it didn't. Must've been something else. Maybe there's something wrong with the part that's supposed to enable the buttons?

NickyNyce

#7
I'm am currently thinking on so many levels right now, I have a puzzle I'm working on that involves lots of objects, views, variables, GUI and buttons. My ears have smoke coming out of them, I must have goofed. But anyway, I see now that return isn't necessary, and things are working, thanks for the help guys.

Happy New Year to you guys as well

SMF spam blocked by CleanTalk