Thread Tools Display Modes
03-24-08, 06:50 PM   #1
Ban-Lord
A Kobold Labourer
Join Date: Mar 2008
Posts: 1
Edit Box

I'm fairly new with LUA, and I'm trying to make a button interact with an edit box. When you press the button, it will say something, like.

"Hey, (text entered)."

How may I do this?

(Name incorporated with the edit box is: plr)
  Reply With Quote
03-24-08, 07:13 PM   #2
Macniel
A Fallenroot Satyr
 
Macniel's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 26
You like to Send a Chat Message with the text of your Editbox when you press your Button? this is easy stuff,

1. you have to get the Text of the Editbox
2. you have to pass it to SendChatMessage function
3. ???
4. profit

you have called your Editbox plr, an Editbox Widget have many methods to deal with it - you can read about them on wowwiki.com

when you come back you know you can use :GetText() to get the text of your Editbox

SendChatMessage (a Wow-Api function) use the first argument for the sending message

so it will looks like this

SendChatMessage(plr:GetText())

easy hu? But it will do nothing, you have to enable your button to be clickable

you use a Widgethandler, to specificate this: "OnClick"

to set a handler to your Object use :SetScript(Handler, function)

it will look like this

YourButton:SetScript("OnClick", function()
SendChatMessage(plr:GetText())
end)

thats it.

to append or preend the Message you use string concatenation ..

modify the secondline to this

SendChatMessage("Hey, "..plr:GetText()..".")

"Hey, ".. is a substring concatenate to plr:GetText() concatenate to .. "."
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Edit Box


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off