Update UI after deleting keyframe

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
MehdiZangenehBar
Posts: 114
Joined: Wed Feb 07, 2024 7:17 pm
Contact:

Update UI after deleting keyframe

Post by MehdiZangenehBar »

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
After keyframe deletetion, timeline will be updated, but viewport and layer window will not update.
User avatar
synthsin75
Posts: 10265
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Update UI after deleting keyframe

Post by synthsin75 »

Have you tried changing the frame and changing back?
User avatar
MehdiZangenehBar
Posts: 114
Joined: Wed Feb 07, 2024 7:17 pm
Contact:

Re: Update UI after deleting keyframe

Post by MehdiZangenehBar »

NO, I found the standard solution which is:
switch_layer:UpdateCurFrame()
Post Reply