73 lines
1.7 KiB
Lua
73 lines
1.7 KiB
Lua
--通用消息弹出框View
|
||
--author:--
|
||
|
||
MsgWindow = {}
|
||
|
||
MsgWindow.MsgMode = {
|
||
OkAndCancel = 1,
|
||
OnlyOk = 2
|
||
}
|
||
MsgWindow.RES_LIST = {
|
||
"MessageBox",
|
||
"MessageBox1"
|
||
}
|
||
|
||
local M = MsgWindow
|
||
|
||
|
||
function MsgWindow.new(blur_view, tip, mode, url, showCheck)
|
||
setmetatable(M, { __index = BaseWindow })
|
||
local self = setmetatable({}, { __index = M })
|
||
self.class = "MsgWindow"
|
||
self._blur_view = blur_view
|
||
self._close_destroy = true
|
||
self._tip = tip
|
||
self._mode = mode
|
||
self.onOk = event("onOk", true)
|
||
self.onCancel = event("onCancel", true)
|
||
self.showCheck = showCheck
|
||
local self_url = url and url or "ui://Common/" .. MsgWindow.RES_LIST[self._mode]
|
||
self:init(self_url)
|
||
return self
|
||
end
|
||
|
||
function M:init(url)
|
||
BaseWindow.init(self, url)
|
||
self._close_destroy = true
|
||
self._close_zone = false
|
||
local view = self._view
|
||
local btn_ok = view:GetChild("btn_ok")
|
||
btn_ok.onClick:Add(function()
|
||
self.onOk()
|
||
self:Destroy()
|
||
end)
|
||
local tex_message = view:GetChild("tex_message")
|
||
tex_message.emojies = EmojiDitc.EmojiesDitc
|
||
if (self._tip) then tex_message.text = self._tip end
|
||
|
||
-- local btn_close = view:GetChild('btn_close1')
|
||
-- if (btn_close~=nil) then
|
||
-- btn_close.onClick:Add(
|
||
-- function()
|
||
-- self:CloseEvent()
|
||
-- end
|
||
|
||
-- )
|
||
-- end
|
||
self.btnCheck = view:GetChild("btnCheck")
|
||
if self.btnCheck then
|
||
self.btnCheck.visible = false
|
||
if self.showCheck then
|
||
self.btnCheck.selected = true
|
||
self.btnCheck.visible = true
|
||
end
|
||
end
|
||
end
|
||
|
||
function M:Close()
|
||
BaseWindow.Close(self)
|
||
if (self._mode == MsgWindow.MsgMode.OkAndCancel) then
|
||
self.onCancel()
|
||
end
|
||
end
|