Need GUI If/Button/TextBox Help
Author |
Message |
Rinaldi363
|
Posted: Thu Oct 27, 2005 3:45 pm Post subject: Need GUI If/Button/TextBox Help |
|
|
Ok... I figured out how to use the button and how to use text box's. For the buttons you need a procedure for it to work (proc). how do I make it so when you press the button something will show up in the text? Also I need to know how to make it so when you click the button, the buttons will disapear so I can make new buttons.
Thanks. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
beard0

|
Posted: Thu Oct 27, 2005 4:38 pm Post subject: (No subject) |
|
|
The reason you need a proc associated with the button is because that is what is run when you click it. GUI.SetText I believ is what is used for the textbox, but you should be able to look it up in the manual. GUI.Dispose gets rid of an element - if you might want it back later, I'm pretty sure there's also a GUI.Hide command available. |
|
|
|
|
 |
Rinaldi363
|
Posted: Thu Oct 27, 2005 5:13 pm Post subject: (No subject) |
|
|
This is jsut a small example of what my basic button/text box is. Now where do I put the Hide? Like so it works when I click the box...
code: | import GUI in "%oot/lib/GUI"
var boxID : int := GUI.CreateTextBox (1, 1, 639, 100)
proc bye
GUI.AddLine (boxID, "Bye")
end bye
var draw : int := GUI.CreateButtonFull (400, 110, 100, "Slash",
bye, 10, '^D', true)
loop
exit when GUI.ProcessEvent
end loop
%Where do I put GUI.Hide (draw) so that it happens after I click the button, but the textbox stays? |
|
|
|
|
|
 |
Rinaldi363
|
Posted: Thu Oct 27, 2005 6:41 pm Post subject: (No subject) |
|
|
Damn... also how do you get a variable in a AddText GUI? like...
code: | randint (weenattack, 0, 4)
elsif weenattack > 0 then
GUI.AddText (boxID, "The goblin attacks you with punch and hits a ")
GUI.AddText (boxID, weenattack)
GUI.AddText (boxID, ".") |
Because weenattack is arandom int variable. |
|
|
|
|
 |
beard0

|
Posted: Fri Oct 28, 2005 11:26 am Post subject: (No subject) |
|
|
code: | import GUI in "%oot/lib/GUI"
var boxID : int := GUI.CreateTextBox (1, 1, 639, 100)
var SlashButton : int
proc bye
GUI.Hide (SlashButton)
GUI.AddLine (boxID, "Bye")
end bye
SlashButton := GUI.CreateButtonFull (400, 110, 100, "Slash",
bye, 10, '^D', true)
loop
exit when GUI.ProcessEvent
end loop |
I changed the name of your button, because "draw" isn't very descriptive. I assume that the rest of the program would give a reason as to why the button is labelled "Slash". The GUI.Hide goes, as I have put it, in the procedure asscoiated with the button. Anything that you want to have happen goes there. This means that you have to declare your variable up above, as I have done.
As to your second question, if you look up the GUI.AddText procedure, you will notice that the second parameter must be of type string. weenattack is an integer, and so you have to convert it to a string before adding it: intstr(weenattack). |
|
|
|
|
 |
Rinaldi363
|
Posted: Mon Oct 31, 2005 4:24 pm Post subject: (No subject) |
|
|
Thanks a lot  |
|
|
|
|
 |
|
|