

OnOKCallback = nil
OnCancelCallback = nil
--message_box_ok

ButtonOK = nil
ButtonNo = nil
ButtonYes = nil

BYesNo = 1
BOK = 2

function OnCreate()
  ButtonOK = self:FindChild("message_box_ok")
  ButtonNo = self:FindChild("message_box_no")
  ButtonYes = self:FindChild("message_box_yes")
end

function OnShow()
  s.sys_message_box  = 1
end

function OnHide()
  OnOKCallback = nil
  OnCancelCallback = nil
  s.sys_message_box  = 0
end


function OnYes()
  local fn = OnOKCallback
  self:SetVisible(false)
  if fn ~= nil then 
    fn()
  end
end

function OnNo()
  local fn = OnCancelCallback
  self:SetVisible(false)
  if fn ~= nil then 
    fn()
  end
end

function OnOK()
  local fn = OnOKCallback
  self:SetVisible(false)
  if fn ~= nil then 
    fn()
  end
end

function SetText(text)
  local txt = self:FindChild("message_box_txt")
  txt:SetText(text)
end

function SetButtons( yes, no, ok)
  ButtonOK:SetVisible(ok)
  ButtonNo:SetVisible(no)
  ButtonYes:SetVisible(yes)
end

function KeyPress(_sender,_key)
    if _key == KC_ESCAPE then
      OnNo()
    end
end