Skip to main content

Popconfirm

Properties

PropertyTypeDescription
titlestringTitle of the popconfirm
cancelTextstringText displayed in the cancel option
okTextstringText displayed in the ok option
descriptionstring, string[]Text displayed in popconfirm
descriptionStyletableCSS Styling for the content of description
disabledbooleanWeather the popconfirm should display
iconstringIcon of the popover
cancelButtonPropstableSee cancelButtonProps
okButtonPropstableSee okButtonProps
okTypestringButton type of ok option
showCancelstringWeather the cancel button should be displayed
onCancelfunction(event)Fired when cancel is pressed
onConfirmfunction(event)Fired when confirm/ok is pressed
onPopupClickfunction(event)Fired when user clicks anywhere in popconfirm
openbooleanControls weather the popconfirm is displayed
All properties are optinoal.

List of Icons can be found here

See more properties here

Children

Popconfirm can have children, by default when a child of popconfirm is clicked/focused it will open.

You can overwrite the open functionality if desired.

Example

AM:createElement("Popconfirm", {
title = "Title",
description = "Are you sure you want to do this task?",
okText = "Yes",
cancelText = "No",
open = false,
onConfirm = function(_, _, event)
print("Clicked Confirm!")
--print("Event: ", json.encode(event))
end,
onCancel = function(_, _, event)
print("Clicked Cancel!")
--print("Event: ", json.encode(event))
end,
-- Fired when user clicks anywhere in the popup.
onPopupClick = function(_, _, event)
print("Clicked Popup!")
print("Event: ", json.encode(event))
end,
}, {
AM:createElement("Button", {text = "Do Task"}),
})

This is how it looks:

In Game

description

Can be either a string or an array containing multiple strings.

description = {"1", "2", "3"} would look like:

image

disabled

When disabled = true the popover will not be displayed when children is clicked/focused.

icon

Change the icon in the pop-left corner of the popover.

icon = "QuestionCircleOutlined"

Looks like:

icon

cancelButtonProps & okButtonProps

Properties of the 2 buttons.

Can be found here or on Ant Design

So if you wanted to give icons to ok/confirm and cancel button, it would look like:

cancelButtonProps = {icon = "ExclamationOutlined"},
okButtonProps = {icon = "CheckSquareOutlined"},

buttonProps

cancelButtonProps

Properties of the cancel button.

Can be found here (Button)

Or on Ant Design

So if you wanted to chance the type of cancel to "primary":

cancelButtonProps = {type = "primary"}

cancelButtonProps

okButtonProps

Properties of the ok/confirm button.

Can be found here (Button)

Or on Ant Design

So if you wanted to chance the type of ok/confirm to "link":

okButtonProps = {type = "link"}

okButtonProps

okType

The type of button the ok/confirm button is.

okType = "link",

okType

showCancel

Weather the cancel button should be displayed.

So if showCancel = false, cancel button will be hidden.

showCancel

onCancel

Event is fired when user clicks the cancel button.

onCancel = function(_, _, event)
print("Clicked Cancel!")
print("Event: ", json.encode(event))
end

onConfirm

Event is fired when user clicks the confirm/ok button.

onConfirm = function(_, _, event)
print("Clicked Confirm!")
print("Event: ", json.encode(event))
end

onPopupClick

Event is fired when user clicks anywhere in the popup/popconfirm.

onPopupClick = function(_, _, event)
print("Clicked in Popup!")
print("Event: ", json.encode(event))
end

open

Controls weather the popconfirm is open or closed, so you can overwrite how the popconfirm will be displayed.

Example
local popconfirm; popconfirm = AM:createElement("Popconfirm", {
title = "Title",
description = "Are you sure you want to do this task?",
okText = "Yes",
cancelText = "No",
open = false,
}, {
AM:createElement("Button", {text = "Do Task"}),
})

local controller; controller = AM:createElement("Button", {
text = "Open Popconfirm!",
onClick = function (id, name, event)
local newState = not popconfirm.open
popconfirm.open = newState
if newState then
controller.text = "Close Popconfirm!"
else
controller.text = "Open Popconfirm!"
end
end,
})

In this example the button within popconfirm does not open it, but the controller button does instead.

Example