that was formally requested back in 2018 ... let's hope the new team are a bit more responsive ...
[Edit]:
I'll reignite that particular flame after 13.5 hits the streets. I think the dev team has got its hands full enough right now ...
Moderators: Víctor Paredes, Belgarath, slowtiger
that was formally requested back in 2018 ... let's hope the new team are a bit more responsive ...
Yes yes yes, this would create tons of possibilities for new tools.
Yesss! This would make some layerscripts obsolete and would be a much user friendlier way to expand rigging possibilities.
I didn't even know this was possible!!! Definitely going to implement this right away. It would be nice to have all of them available.synthsin75 wrote: ↑Mon Mar 15, 2021 4:51 pmEven if just the Alt modifier were available for toolbar buttons, just like we have for GUI buttons: http://mohoscripting.com/methods/1051
Maybe I'm not understanding this correctly, but I just read some code and I think it's actually possible to add the moho object to the UpdateWidgets method of a non-modal dialogue... Check out the LM_Set_Origin.lua tool. It actually creates a modeless window in DoLayout, but the code is commented out.
Code: Select all
--if (self.layerSettingsWnd == nil) then
-- self.layerSettingsWnd = LM_LayerSettingsDialog:new()
-- self.layerSettingsWnd:DoModeless()
--end
Code: Select all
-- register the layer window to be updated when changes are made
table.insert(MOHO.UpdateTable, LM_LayerSettingsDialog_Update)
Code: Select all
function LM_LayerSettingsDialog_Update(moho)
Well, the dialog in LM_SetOrigin actually gets changes from Moho after being invoked. Or is that also possible with the method you just mentioned? I think I'm in over my head here...synthsin75 wrote: ↑Sat Apr 10, 2021 11:04 pmBut that window will not be able to get changes from Moho, like the current frame, if changed since the window was invoked.
I have to investigate that further. I've never seen something like a table.insert called outside of a function, which would insert it when the tool was loaded by Moho.Lukas wrote: ↑Sat Apr 10, 2021 11:16 pmWell, the dialog in LM_SetOrigin actually gets changes from Moho after being invoked. Or is that also possible with the method you just mentioned? I think I'm in over my head here...synthsin75 wrote: ↑Sat Apr 10, 2021 11:04 pmBut that window will not be able to get changes from Moho, like the current frame, if changed since the window was invoked.
Now that is interesting -- the table MOHO.UpdateTable and the function MOHO.RunUpdateTable have been there since at least 12.5 -- I haven't dug deeper into the past. The function is described briefly in http://mohoscripting.com/lm_utilitiesLukas wrote: ↑Sat Apr 10, 2021 10:43 pm Maybe I'm not understanding this correctly, but ... the LM_Set_Origin.lua tool ... contains:Which actually triggers the dialog to update during updates, and it passes moho...?Code: Select all
-- register the layer window to be updated when changes are made table.insert(MOHO.UpdateTable, LM_LayerSettingsDialog_Update)
Code: Select all
function LM_LayerSettingsDialog_Update(moho)
Code: Select all
MOHO.UpdateTable = {}
function MOHO.RunUpdateTable(moho)
for i, func in ipairs(MOHO.UpdateTable) do
func(moho)
end
end
Code: Select all
function HS_ForUpdate(moho)
local t = type (moho.frame)
Print ("I'm here!!", t)
end
--
table.insert(MOHO.UpdateTable, HS_ForUpdate)
I've also been dabbling and it's all very confusing...hayasidist wrote: ↑Thu Aug 05, 2021 10:10 amHowever, the "moho" that the called routine gets doesn't seem to be the same as I was expecting - the above reports t as "nil" ... maybe something wrong with the way I'm setting things up -- but right now I'm at a bit of a brick wall.
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "LK_Experiment"
-- **************************************************
-- General information about this script
-- **************************************************
LK_Experiment = {}
LK_Experiment.BASE_STR = 2325
function LK_Experiment:Name()
return "LK_Experiment...Name"
end
function LK_Experiment:Version()
return "0.1"
end
function LK_Experiment:Description()
return "LK_Experiment...Description"
end
function LK_Experiment:Creator()
return "Lukas Krepel, Frame Order"
end
function LK_Experiment:UILabel()
return "LK_Experiment...UILabel"
end
function LK_Experiment:ColorizeIcon()
return true
end
-- **************************************************
-- Recurring values
-- **************************************************
LK_Experiment.matrix = LM.Matrix:new_local()
LK_Experiment.experimentalWindow = nil
-- **************************************************
-- The guts of this script
-- **************************************************
function LK_Experiment:OnInputDeviceEvent(moho, deviceEvent)
--
end
function LK_Experiment:OnMouseDown(moho, mouseEvent)
--
end
function LK_Experiment:OnMouseMoved(moho, mouseEvent)
--
end
-- **************************************************
-- Layer Settings dialog
-- **************************************************
local LK_ExperimentDialog = {}
LK_ExperimentDialog.CHANGE = MOHO.MSG_BASE
LK_ExperimentDialog.XPOS = MOHO.MSG_BASE + 1
function LK_ExperimentDialog:new()
local d = LM.GUI.SimpleDialog("Experimental Window", LK_ExperimentDialog)
local l = d:GetLayout()
l:PushH()
d.frame = LM.GUI.DynamicText("Frame 00000", 80)
l:AddChild(d.frame, LM.GUI.ALIGN_LEFT)
-- * LM.GUI.Slider(length, vertical, showTicks, msg, resizingMode)
d.slider = LM.GUI.Slider(200, false, false, LK_ExperimentDialog.CHANGE, LM_FOLLOW_LEFT)
l:AddChild(d.slider)
l:Pop()
l:PushH()
l:AddChild(LM.GUI.StaticText("Layer X translation:"))
d.pX = LM.GUI.TextControl(0, "00.0000", LK_ExperimentDialog.XPOS, LM.GUI.FIELD_FLOAT)
l:AddChild(d.pX, LM.GUI.ALIGN_LEFT)
l:Pop()
return d
end
function LK_ExperimentDialog:Update(moho)
if (moho.layer == nil) then
-- print ("moho.layer == nil (?!)")
return
end
-- print ("moho.layer ~= nil (WHAT?)")
self.frame:SetValue("Frame "..moho.frame)
self.slider:SetRange(moho.document:StartFrame(), moho.document:EndFrame())
self.slider:SetValue(moho.frame)
local layer = moho.layer
self.pX:SetValue(layer.fTranslation.value.x)
end
function LK_ExperimentDialog:OnOK()
LK_Experiment.experimentalWindow = nil -- mark the window closed
end
function LK_ExperimentDialog_Update(moho)
if (LK_Experiment.experimentalWindow) then
LK_Experiment.experimentalWindow:Update(moho)
end
end
-- register the layer window to be updated when changes are made
table.insert(MOHO.UpdateTable, LK_ExperimentDialog_Update)
-- **************************************************
-- Tool options - create and respond to tool's UI
-- **************************************************
LK_Experiment.CHANGE = MOHO.MSG_BASE
LK_Experiment.XPOS = MOHO.MSG_BASE + 1
function LK_Experiment:DoLayout(moho, layout)
if (self.experimentalWindow == nil) then
self.experimentalWindow = LK_ExperimentDialog:new()
self.experimentalWindow:DoModeless()
end
end
function LK_Experiment:UpdateWidgets(moho)
if (self.experimentalWindow) then
self.experimentalWindow:Update(moho)
end
end
function LK_Experiment:HandleMessage(moho, view, msg)
if (msg == self.CHANGE) then
-- * Slide to new frame:
local newFrame = LK_Experiment.experimentalWindow.slider:Value()
moho:SetCurFrame(newFrame)
end
if (msg == self.XPOS) then
-- * Prep undo:
moho.document:PrepUndo(moho.layer, true)
moho.document:SetDirty()
-- * Key layer translation:
local layerPos = moho.layer.fTranslation:GetValue(moho.frame)
layerPos:Set (LK_Experiment.experimentalWindow.pX:FloatValue(), layerPos.y, layerPos.z)
moho.layer.fTranslation:SetValue(moho.frame, layerPos)
-- * Update timeline:
moho:UpdateUI()
end
end
Code: Select all
function LM_SomeOtherTool:HandleMessage(moho, view, msg)
LK_Experiment:HandleMessage(moho, view, msg)
Code: Select all
function LM_SomeOtherTool:UpdateWidgets(moho)
if (LK_Experiment.experimentalWindow) then
LK_Experiment.experimentalWindow:Update(moho)
end
Code: Select all
-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************
ScriptName = "LK_Experiment"
-- **************************************************
-- General information about this script
-- **************************************************
LK_Experiment = {}
function LK_Experiment:Name()
return "LK_Experiment...Name"
end
function LK_Experiment:Version()
return "0.1"
end
function LK_Experiment:Description()
return "LK_Experiment...Description"
end
function LK_Experiment:Creator()
return "Lukas Krepel, Frame Order"
end
function LK_Experiment:UILabel()
return "LK_Experiment...UILabel"
end
function LK_Experiment:ColorizeIcon()
return true
end
-- **************************************************
-- Layer Settings dialog
-- **************************************************
local LK_ExperimentDialog = {}
function LK_ExperimentDialog:new()
local d = LM.GUI.SimpleDialog("Experimental Window", LK_ExperimentDialog)
local l = d:GetLayout()
l:PushH()
d.frame = LM.GUI.DynamicText("Frame 00000", 80)
l:AddChild(d.frame, LM.GUI.ALIGN_LEFT)
d.slider = LM.GUI.Slider(200, false, false, LK_Experiment.CHANGE, LM_FOLLOW_LEFT) -- * LM.GUI.Slider(length, vertical, showTicks, msg, resizingMode)
l:AddChild(d.slider)
l:Pop()
l:PushH()
l:AddChild(LM.GUI.StaticText("Layer X translation:"))
d.pX = LM.GUI.TextControl(0, "00.0000", LK_Experiment.XPOS, LM.GUI.FIELD_FLOAT)
l:AddChild(d.pX, LM.GUI.ALIGN_LEFT)
l:Pop()
return d
end
function LK_ExperimentDialog:Update(moho)
if (moho.layer == nil) then
-- print ("moho.layer == nil (?!)")
return
end
-- print ("moho.layer ~= nil (WHAT?)")
self.frame:SetValue("Frame "..moho.frame)
self.slider:SetRange(moho.document:StartFrame(), moho.document:EndFrame())
self.slider:SetValue(moho.frame)
local layer = moho.layer
self.pX:SetValue(layer.fTranslation.value.x)
end
function LK_ExperimentDialog:OnOK()
experimentalWindow = nil -- mark the window closed
end
function LK_ExperimentDialog_Update(moho)
if (experimentalWindow) then
experimentalWindow:Update(moho)
end
end
-- register the layer window to be updated when changes are made
table.insert(MOHO.UpdateTable, LK_ExperimentDialog_Update)
-- **************************************************
-- Tool options - create and respond to tool's UI
-- **************************************************
LK_Experiment.MSG_BASE = 2000 -- * Might conflict with other tools!
LK_Experiment.CHANGE = MOHO.MSG_BASE + LK_Experiment.MSG_BASE + 0
LK_Experiment.XPOS = MOHO.MSG_BASE + LK_Experiment.MSG_BASE + 1
function LK_Experiment:Run(moho)
if (experimentalWindow == nil) then
experimentalWindow = LK_ExperimentDialog:new()
experimentalWindow:DoModeless()
end
end
function LK_Experiment:HandleMessage(moho, view, msg)
-- print ("msg "..msg)
if (msg == self.CHANGE) then
-- * Slide to new frame:
local newFrame = experimentalWindow.slider:Value()
moho:SetCurFrame(newFrame)
end
if (msg == self.XPOS) then
-- * Prep undo:
moho.document:PrepUndo(moho.layer, true)
moho.document:SetDirty()
-- * Key layer translation:
local layerPos = moho.layer.fTranslation:GetValue(moho.frame)
layerPos:Set (experimentalWindow.pX:FloatValue(), layerPos.y, layerPos.z)
moho.layer.fTranslation:SetValue(moho.frame, layerPos)
-- * Update timeline:
moho:UpdateUI()
end
end
Code: Select all
function LM_SomeOtherTool:HandleMessage(moho, view, msg)
function LM_AddPoint:HandleMessage(moho, view, msg)
LK_Experiment:HandleMessage(moho, view, msg)
if msg >= MOHO.MSG_BASE + LK_Experiment.MSG_BASE then -- * Might conflict with the original tools intentions!
return
end
Code: Select all
function LM_SomeOtherTool:UpdateWidgets(moho)
LK_ExperimentDialog_Update(moho)
Code: Select all
LK_Experiment.MSG_BASE = 2000 -- * Might conflict with other tools!
LK_Experiment.CHANGE = MOHO.MSG_BASE + LK_Experiment.MSG_BASE + 0
LK_Experiment.XPOS = MOHO.MSG_BASE + LK_Experiment.MSG_BASE + 1
Ahh, yes, because the addpoint tool's handlemessage checks for "elseif (msg >= self.SELECTITEM) then" it will likely always trigger a part of that code which is not supposed to run and throw an error... I'm don't really understand how MSG_BASE works and what its min/max values are. There's probably no sure way to make sure the msg integers of the modal window won't overlap with the tools without modifying some of them.synthsin75 wrote: ↑Thu Aug 05, 2021 5:37 pm The experimental menu script just throws an error from the AddPoint tool. Likely due to that MSG_BASE.
Code: Select all
function LM_AddPoint:HandleMessage(moho, view, msg)
LK_Experiment:HandleMessage(moho, view, msg)
if msg >= MOHO.MSG_BASE + LK_Experiment.MSG_BASE then
return
end
[...]
has anyone found / got access to the code for the LM_LayerSettingsDialog_Update function? How that handles the "moho" param would be very illuminating!Lukas wrote: ↑Sat Apr 10, 2021 10:43 pm Check out the LM_Set_Origin.lua tool ... the tool also contains:Code: Select all
-- register the layer window to be updated when changes are made table.insert(MOHO.UpdateTable, LM_LayerSettingsDialog_Update)