Page 1 of 1
Deactivate an action?
Posted: Tue Dec 22, 2015 9:31 pm
by strider2000
Is there a correct way to programmatically return to the --- Mainline ---. I know how to activate an action. I tried Activating "Mainline" and "--- Mainline ---" but that didn't seem to work. It does seem that if I create a junk action and then delete it then I accomplish what I want, but that really doesn't seem to be the elegant approach
Re: Deactivate an action?
Posted: Tue Dec 22, 2015 11:17 pm
by Stan
If you don't care for older versions (earlier than 10.0), then you can just use this:
Code: Select all
moho.document:SetCurrentDocAction(nil)
However, if you do care for older versions, here is the correct way to do it (complete button-script):
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "SZ_ActivateMainline"
-- **************************************************
-- General information about this script
-- **************************************************
SZ_ActivateMainline = {}
function SZ_ActivateMainline:Name()
return "Activate Mainline"
end
function SZ_ActivateMainline:Version()
return "1.0"
end
function SZ_ActivateMainline:Description()
return "Quit edit action and go to mainline"
end
function SZ_ActivateMainline:Creator()
return "Stan aka Vodka"
end
function SZ_ActivateMainline:UILabel()
return "Activate Mainline"
end
-- **************************************************
-- The guts of this script
-- **************************************************
function SZ_ActivateMainline:IsEnabled(moho)
if moho.layer:CurrentAction() ~= "" then
return true
end
return false
end
function SZ_ActivateMainline:IsRelevant(moho)
return true
end
function SZ_ActivateMainline:Run(moho)
if moho.layer:CurrentAction() ~= "" then
local version = 9.0
if moho.AppVersion ~= nil then
local sVersion = string.gsub(moho:AppVersion(), "^(%d+)(%.%d+)(%..+)", "%1%2")
version = tonumber(sVersion)
-- print(sVersion)
end
if version >= 10.0 then
moho.document:SetCurrentDocAction(nil)
end
moho.layer:ActivateAction(nil)
moho.layer:UpdateCurFrame()
moho:UpdateUI()
end
end
And here's the icon:
Re: Deactivate an action?
Posted: Wed Dec 23, 2015 12:43 am
by strider2000
Much thanks Stan
Very much appreciated. 10+ is good for me.