Deactivate an action?
Moderators: Víctor Paredes, Belgarath, slowtiger
- strider2000
- Posts: 506
- Joined: Sat Mar 07, 2015 5:14 pm
- Contact:
Deactivate an action?
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?
If you don't care for older versions (earlier than 10.0), then you can just use this:
However, if you do care for older versions, here is the correct way to do it (complete button-script):
And here's the icon:
Code: Select all
moho.document:SetCurrentDocAction(nil)
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
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
- strider2000
- Posts: 506
- Joined: Sat Mar 07, 2015 5:14 pm
- Contact:
Re: Deactivate an action?
Much thanks Stan Very much appreciated. 10+ is good for me.