-- NOTE: This handler object is auto-generated. Feel free to modify the contents of this file.
--
-- IMPORTANT: This script resource must be attached to a script component named WidgetHandler to work
--            with the checkbox widget's base script.
-- 

local thisActor = ...;
local actorName = scaleform.Actor.name(thisActor);

local container = scaleform.Actor.container(thisActor);
local background_normal = scaleform.ContainerComponent.actor_by_name(container, "background_normal");
local content_normal = scaleform.ContainerComponent.actor_by_name(container, "content_normal");
local background_checked = scaleform.ContainerComponent.actor_by_name(container, "background_checked");
local content_checked = scaleform.ContainerComponent.actor_by_name(container, "content_checked");

scaleform.Actor.set_visible(background_normal, false);
scaleform.Actor.set_visible(content_normal, false);
scaleform.Actor.set_visible(background_checked, true);
scaleform.Actor.set_visible(content_checked, true);

-- The handler object expected by the base widget script
-- If any of the handler methods are not defined, then the base widget will not attempt to invoke them.
local handler = {
    	
	-- Invoked when the checkbox is clicked
	-- Param checked : Boolean
	clicked = function(checked)
	-- work around below
	local checked_float = 0
		if checked then checked_float = 1 end
	        local evt = { eventId = scaleform.EventTypes.Custom, 
	                      name = "action", 
	                      data = { message = "sound_toggled", value = checked_float } }
	        scaleform.Stage.dispatch_event(evt)
		end
}

return handler;