MessageBox
A window showing some text and buttons.
Module | require("yue.gui") |
Type | Class |
Class methods
create()
Create a message box.
Return
MessageBox
Methods
run()
Show the message box and wait for result. Response ID will be returned.
Return
integer
runforwindow(window)
Show the message box as a child for window
and wait for result.
Response ID will be returned.
Parameters
Window
window
Return
integer
Windows Linux
show()Show the message box. The onresponse
event will be emitted when
the message box is closed.
showforwindow(window)
Show the message box as a child of window
. The onresponse
event will be emitted when the message box is closed.
Parameters
Window
window
close()
Close the message box. The cancel response ID will be used as result.
settype(type)
Set the type
of message box, system will show the corresponding icon in
the message box.
On macOS there is no visual difference between information
and warning
types.
On Linux this method has no effect if a custom icon has been set.
Parameters
MessageBox::Type
type
Windows Linux
settitle(title)Set the message box window's title.
Parameters
string
title
addbutton(title, response)
Add a button with title
. The response
ID will be used as result when
the button is clicked.
Parameters
string
titleinteger
response
setdefaultresponse(response)
Set the default response
ID, when user presses the Enter key
the button associated with the ID will be clicked.
Parameters
integer
response
setcancelresponse(response)
Set the cancel response
ID that will be used as result when user
presses the Esc key or when the window is closed without
clicking any button.
The default cancel response ID is -1.
Parameters
integer
response
settext(text)
Set the message box's message text.
Parameters
string
text
setinformativetext(text)
Set informative text that will show bellow the message text.
Parameters
string
text
macOS Linux
setaccessoryview(view)Set the accessory view
that will be placed between the text and the
buttons. The view
must be given a size before being used as accessory
view.
Parameters
View
view
macOS Linux
getaccessoryview()Return the accessory view.
Return
View
setimage(image)
Set the custom icon displayed in the message box.
On macOS the default icon is the app's icon, on Windows and Linux there is no default icon.
Parameters
Image
image
getimage()
Return the custom icon.
Return
Image
Events
onresponse(self, response)
Emitted when the message box is closed.
Parameters
MessageBox
selfinteger
response