Select layer and update tool?

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
bbrraayyaann
Posts: 68
Joined: Thu Jan 24, 2019 3:52 am

Select layer and update tool?

Post by bbrraayyaann »

Hello friends, how are you.
I am using the function: ScriptInterface:SetSelLayer(layer) to select a layer, but for example if I am in a bone layer and I select a vector layer, it does not update its corresponding tool, when I select the vector it should change to drawing tool, but it stays in the bone tool for example. Would anyone please know how to do it?
bbrraayyaann
Posts: 68
Joined: Thu Jan 24, 2019 3:52 am

Re: Select layer and update tool?

Post by bbrraayyaann »

I was going through scripts and came across this.
I have also tried everything; but I think this is the only solution?
If there is another way let me know.

This script: https://mohoscripts.com/script/sz_layer ... on_buttons

Code: Select all

					-- These are the methods I tried, and none of them updates the tool panel:
					-- moho:UpdateUI()				
					-- moho.view:DrawMe()
					-- moho.view:RefreshView()
					-- layer:UpdateCurFrame(true)
					-- MOHO.Redraw()
					-- moho:UpdateSelectedChannels()
					-- moho:UpdateBonePointSelection()
				-- That's why we have to do some dark magic here instead:
				local sacrificialLayer = moho:CreateNewLayer(MOHO.LT_UNKNOWN)
				moho:DeleteLayer(sacrificialLayer)
User avatar
synthsin75
Posts: 9978
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Select layer and update tool?

Post by synthsin75 »

You might also try jumping to/from frame zero and back. That's another thing that reliably reevaluates the tools window.
bbrraayyaann
Posts: 68
Joined: Thu Jan 24, 2019 3:52 am

Re: Select layer and update tool?

Post by bbrraayyaann »

But it works when you use PickGlobalLayer :

Code: Select all

function Pickckckc:OnMouseUp(moho, mouseEvent)
	local layer = mouseEvent.view:PickGlobalLayer(mouseEvent.pt)
	if layer == nil then return end
	
	if (layer == nil or layer == moho.layer) then
		return
	end
	moho.document:ClearSecondarySelection()	
	moho:SetSelLayer(layer)
	moho:ShowLayerInLayersPalette(layer)
	moho:UpdateUI()
end
bbrraayyaann
Posts: 68
Joined: Thu Jan 24, 2019 3:52 am

Re: Select layer and update tool?

Post by bbrraayyaann »

synthsin75 wrote: Thu Feb 09, 2023 12:57 am You might also try jumping to/from frame zero and back. That's another thing that reliably reevaluates the tools window.
Ah, that works well too, thanks
Post Reply