Update UI after deleting keyframe
Posted: Tue Jun 04, 2024 7:15 am
				
				Code: Select all
-- **************************************************
-- General information about this script
-- **************************************************
ScriptName = "Test_Script"
Test_Script = {}
function Test_Script:Name()
	return 'Test Script'
end
function Test_Script:Version()
	return '1.0'
end
function Test_Script:UILabel()
	return 'Test Script'
end
function Test_Script:Creator()
	return 'Test'
end
function Test_Script:Description()
	return 'Test'
end
-- **************************************************
-- Is Relevant / Is Enabled
-- **************************************************
function Test_Script:IsRelevant(moho)
	return true
end
function Test_Script:IsEnabled(moho)
	return true
end
-- **************************************************
-- Tool Panel Layout
-- **************************************************
Test_Script.msg_delete_keyframe = MOHO.MSG_BASE
function Test_Script:DoLayout(moho, layout)
	layout:AddChild(LM.GUI.Button('Delete Keyframe', self.msg_delete_keyframe), LM.GUI.ALIGN_LEFT, 0)
end
-- **************************************************
-- Events
-- **************************************************
function Test_Script:OnMouseDown(moho, mouseEvent)
end
function Test_Script:HandleMessage(moho, view, msg)
	if msg == self.msg_delete_keyframe then
		if moho:LayerAsSwitch(moho.layer) then
			local current_frame = moho.frame
			local switch_layer = moho.layer
			local switch_channel = switch_layer:SwitchValues()
			if switch_channel:HasKey(current_frame) then
				switch_channel:DeleteKey(current_frame)
				moho:UpdateUI()
				MOHO.Redraw()
			end
		end
	end
end