Skip to main content
Skip to main content

DialogElement

DialogElement

Description

Base element for modal dialogs. Dialogs are a specialization of ScreenElement, but work mostly the same in terms of loading and configuration. Much like screens, dialogs are controlled and configured by correspondingly named [dialogName]Dialog.lua and [dialogName]Dialog.xml files.

Parent

ScreenElement

Functions

close

Description

Definition

close()

Code

function DialogElement:close()
g_gui:closeDialogByName( self.name)
end

new

Description

Definition

new()

Arguments

anytarget
anycustom_mt

Code

function DialogElement.new(target, custom_mt)
local self = ScreenElement.new(target, custom_mt or DialogElement _mt)

self.isCloseAllowed = true

return self
end

onClickBack

Description

Definition

onClickBack()

Arguments

anyforceBack
anyusedMenuButton

Code

function DialogElement:onClickBack(forceBack, usedMenuButton)
if ( self.isCloseAllowed or forceBack) and not usedMenuButton then
self:close()
return false -- event used
else
return true -- event unused
end
end

setDialogType

Description

Definition

setDialogType()

Arguments

anydialogType

Code

function DialogElement:setDialogType(dialogType)
dialogType = dialogType or DialogElement.TYPE_WARNING
self.dialogType = dialogType

-- apply element visibility based on dialog type
for dt, id in pairs(TYPE_ICON_ID_MAPPING) do
local typeElement = self [id]
if typeElement then
typeElement:setVisible(dt = = dialogType)
end
end

if self.dialogCircle ~ = nil then
self.dialogCircle:setVisible(dialogType ~ = DialogElement.TYPE_LOADING)

-- apply circle profile
if dialogType = = DialogElement.TYPE_WARNING then
self.dialogCircle:applyProfile( DialogElement.DIALOG_CIRCLE_PROFILE_WARNING)
else
self.dialogCircle:applyProfile( DialogElement.DIALOG_CIRCLE_PROFILE)
end
end
end

setIsCloseAllowed

Description

Definition

setIsCloseAllowed()

Arguments

anyisAllowed

Code

function DialogElement:setIsCloseAllowed(isAllowed)
self.isCloseAllowed = isAllowed
end