WoW:Creating simple pop-up dialog boxes: Difference between revisions

(edited the example of passing arguments to local functions for clarification)
(Typo fixing using AWB)
Line 88: Line 88:
  OnShow = function()
  OnShow = function()
     getglobal(this:GetName().."EditBox"):SetText("Some data")
     getglobal(this:GetName().."EditBox"):SetText("Some data")
     -- notice: "this" is the StaticPopup, normaly its "StaticPopup1"
     -- notice: "this" is the StaticPopup, normally its "StaticPopup1"
  end,
  end,
  OnAccept = function()
  OnAccept = function()
     getglobal(this:GetParent():GetName().."EditBox"):GetText()
     getglobal(this:GetParent():GetName().."EditBox"):GetText()
     -- do whatever you want with it
     -- do whatever you want with it
     -- notice: "this" is the left button, normaly its "StaticPopup1Button1",
     -- notice: "this" is the left button, normally its "StaticPopup1Button1",
     --        so you need the GetParent() call.
     --        so you need the GetParent() call.
  end,
  end,
Line 168: Line 168:
* Added by [[user:Layrajha|Layrajha]]: The OnHide function will always be called after OnAccept or OnCancel have finished their execution. Therefore, it is safe to assume that your changes done in OnAccept or OnCancel will be done when OnHide is called. Also note that you can prevent the popup from hiding after clicking the "Accept" button: just make the OnAccept function return "true" (or anything different from "nil" and "false", it will work just as well).
* Added by [[user:Layrajha|Layrajha]]: The OnHide function will always be called after OnAccept or OnCancel have finished their execution. Therefore, it is safe to assume that your changes done in OnAccept or OnCancel will be done when OnHide is called. Also note that you can prevent the popup from hiding after clicking the "Accept" button: just make the OnAccept function return "true" (or anything different from "nil" and "false", it will work just as well).


[[Category: HOWTOs|Popup Simple Dialog Boxes]]
[[Category:HOWTOs|Popup Simple Dialog Boxes]]
Anonymous user