Difference between revisions of "love.window.showMessageBox"
(Created page) |
m (Updated function argument order) |
||
Line 6: | Line 6: | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | success = love.window.showMessageBox( | + | success = love.window.showMessageBox( title, message, type, attachtowindow ) |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | |||
{{param|string|title|The title of the message box.}} | {{param|string|title|The title of the message box.}} | ||
{{param|string|message|The text inside the message box.}} | {{param|string|message|The text inside the message box.}} | ||
+ | {{param|MessageBoxType|type ("info")|The type of the message box.}} | ||
{{param|boolean|attachtowindow (true)|Whether the message box should be attached to the love window or free-floating.}} | {{param|boolean|attachtowindow (true)|Whether the message box should be attached to the love window or free-floating.}} | ||
=== Returns === | === Returns === | ||
Line 20: | Line 20: | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | pressedbutton = love.window.showMessageBox( | + | pressedbutton = love.window.showMessageBox( title, message, buttonlist, type, attachtowindow ) |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | |||
{{param|string|title|The title of the message box.}} | {{param|string|title|The title of the message box.}} | ||
{{param|string|message|The text inside the message box.}} | {{param|string|message|The text inside the message box.}} | ||
{{param|table|buttonlist|A table containing a list of button names to show. The table can also contain the fields <code>enterbutton</code> and <code>escapebutton</code>, which should be the index of the default button to use when the user presses 'enter' or 'escape', respectively.}} | {{param|table|buttonlist|A table containing a list of button names to show. The table can also contain the fields <code>enterbutton</code> and <code>escapebutton</code>, which should be the index of the default button to use when the user presses 'enter' or 'escape', respectively.}} | ||
+ | {{param|MessageBoxType|type ("info")|The type of the message box.}} | ||
{{param|boolean|attachtowindow (true)|Whether the message box should be attached to the love window or free-floating.}} | {{param|boolean|attachtowindow (true)|Whether the message box should be attached to the love window or free-floating.}} | ||
=== Returns === | === Returns === | ||
Line 39: | Line 39: | ||
if not love.graphics.isSupported("shader") then | if not love.graphics.isSupported("shader") then | ||
− | love.window.showMessageBox("error" | + | love.window.showMessageBox(errortitle, errormessage, "error") |
end | end | ||
</source> | </source> | ||
Line 49: | Line 49: | ||
local buttons = {"OK", "No!", "Help", escapebutton = 2} | local buttons = {"OK", "No!", "Help", escapebutton = 2} | ||
− | local pressedbutton = love.window.showMessageBox( | + | local pressedbutton = love.window.showMessageBox(title, message, buttons) |
if pressedbutton == 1 then | if pressedbutton == 1 then | ||
-- "OK" was pressed | -- "OK" was pressed |
Latest revision as of 03:34, 23 October 2014
Available since LÖVE 0.9.2 |
This function is not supported in earlier versions. |
Displays a message box dialog above the love window. The message box contains a title, optional text, and buttons.
This function will pause all execution of the main thread until the user has clicked a button to exit the message box. Calling the function from a different thread may cause love to crash. |
Contents
Function
Displays a simple message box with a single 'OK' button.
Synopsis
success = love.window.showMessageBox( title, message, type, attachtowindow )
Arguments
string title
- The title of the message box.
string message
- The text inside the message box.
MessageBoxType type ("info")
- The type of the message box.
boolean attachtowindow (true)
- Whether the message box should be attached to the love window or free-floating.
Returns
boolean success
- Whether the message box was successfully displayed.
Function
Displays a message box with a customized list of buttons.
Synopsis
pressedbutton = love.window.showMessageBox( title, message, buttonlist, type, attachtowindow )
Arguments
string title
- The title of the message box.
string message
- The text inside the message box.
table buttonlist
- A table containing a list of button names to show. The table can also contain the fields
enterbutton
andescapebutton
, which should be the index of the default button to use when the user presses 'enter' or 'escape', respectively. MessageBoxType type ("info")
- The type of the message box.
boolean attachtowindow (true)
- Whether the message box should be attached to the love window or free-floating.
Returns
number pressedbutton
- The index of the button pressed by the user. May be 0 if the message box dialog was closed without pressing a button.
Examples
Display a simple message box if the user's system doesn't support shaders
local errortitle = "Shader support is required for the game to run"
local errormessage = "This system is below the minimum system requirements for the game.\
If your graphics drivers aren't up-to-date, try updating them and running the game again."
if not love.graphics.isSupported("shader") then
love.window.showMessageBox(errortitle, errormessage, "error")
end
Display a message box with customized buttons
local title = "This is a title"
local message = "This is some text"
local buttons = {"OK", "No!", "Help", escapebutton = 2}
local pressedbutton = love.window.showMessageBox(title, message, buttons)
if pressedbutton == 1 then
-- "OK" was pressed
elseif pressedbutton == 2 then
-- etc.
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info