Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:Creating simple pop-up dialog boxes
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Advanced setup == * ''OnAccept'' - This function can take up to two arguments, both optional. They are for passing arbitrary data around the callbacks. In general this is used with dialogs that have an editable text field, to pass the entered text back to the function; also for chaining dialog boxes together. For details, see "Passing arguments to local functions" below. * ''OnCancel'' - This function can take up to two arguments, both optional. The first is used the same way as the first parameter in OnAccept (whatever that may actually be). The second is a string describing the reason the popup was cancelled; the game will pass this as required: ** "override" - Another popup cancelled this one, or is set to 'exclusive' (see below), or the player is dead or logging out. ** "timeout" - The popup's entry specified a nonzero timeout field, and the time expired. ** "clicked" - The player clicked button2, or hit the escape key and hideOnEscape is set. === Dialog text parameters === The ''text'' field of an entry can contain formatting placeholders. When the popup is actually displayed, the calling function can pass two additional arguments to <tt>StaticPopup_Show</tt>. The ''text'' field and these two arguments will be passed through the [[API_format|format]] function before being added to the dialog. For example, the default guild invitation popup sets <tt>text = "%s invites you to join %s"</tt>, and the display call is to <tt>StaticPopup_Show ("GUILD_INVITE", name_of_officer, name_of_guild)</tt>. === Editable text fields === To add a editbox in the popup set the ''hasEditBox'' option field to true. The EditBox gets the name "$parentEditBox", relative to the Popup, and is also available in the popup's ''.editBox'' field. (Recall that the popup dialog is the value returned from the ''StaticPopup_Show()'' function.) To get and set the value of the EditBox use the following code: OnShow = function (self, data) self.editBox:SetText("Some text goes here") end, OnAccept = function (self, data, data2) local text = self.editBox:GetText() -- do whatever you want with it end, hasEditBox = true More complicated usage might be to use OnShow to call <tt>self.button1:Disable()</tt> (graying out the Accept button), and then including the following in your options table to allow the Accept button to be clicked as soon as the user types something in the text field: EditBoxOnTextChanged = function (self, data) -- careful! 'self' here points to the editbox, not the dialog self:GetParent().button1:Enable() -- self:GetParent() is the dialog end Using ''hasEditBox''/''.editBox'' causes a small one-line text field to appear. You can use the ''hasWideEditBox'' option field (and the corresponding ''.wideEditBox'' dialog field) to cause the text field to have the full width of the dialog box instead. To do this, you must set both options, but only the wide edit box will be used. Both normal and wide editboxes will respect the ''maxLetters'' field if you set it (most editbox popups used by Blizzard set this to 24 or 31).
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)