Page 1 of 1

make layer unselectable?

Posted: Thu Sep 02, 2021 11:01 am
by davoodice2
can be done though script?

Re: make layer unselectable?

Posted: Thu Sep 02, 2021 1:44 pm
by hayasidist
you can lock a layer via scripting: https://mohoscripting.com/methods/576 but it can still be selected

Re: make layer unselectable?

Posted: Thu Sep 02, 2021 5:23 pm
by synthsin75
From my lock layer script:

Code: Select all

function Syn_LockLayer:IsRelevant(moho)
	--keep locked layer from being selected
	if (moho.frame > 0) and (moho.layer:IsLocked()) and (self.lastLayer) and (moho.document:IsLayerValid(self.lastLayer)) then
		moho:SetSelLayer(self.lastLayer)
	end
	self.lastLayer = moho.layer
end
On frames > 0, selecting a locked layer instantly selects the last selected layer. For the user, it just looks like they can't select that layer.


EDIT: Forgot to include the assignment of self.lastLayer

Re: make layer unselectable?

Posted: Fri Sep 03, 2021 12:42 am
by Greenlaw
Oh, that's clever! :D

Re: make layer unselectable?

Posted: Fri Sep 03, 2021 8:03 am
by davoodice2
synthsin75 wrote: Thu Sep 02, 2021 5:23 pm From my lock layer script:

Code: Select all

function Syn_LockLayer:IsRelevant(moho)
	--keep locked layer from being selected
	if (moho.frame > 0) and (moho.layer:IsLocked()) and (self.lastLayer) and (moho.document:IsLayerValid(self.lastLayer)) then
		moho:SetSelLayer(self.lastLayer)
	end
	self.lastLayer = moho.layer
end
On frames > 0, selecting a locked layer instantly selects the last selected layer. For the user, it just looks like they can't select that layer.


EDIT: Forgot to include the assignment of self.lastLayer
very interested! . now is it possible to change it to ignore locked layer and select behind layer?

Re: make layer unselectable?

Posted: Fri Sep 03, 2021 5:52 pm
by synthsin75
davoodice2 wrote: Fri Sep 03, 2021 8:03 am very interested! . now is it possible to change it to ignore locked layer and select behind layer?
I don't understand.

How do you want to define an unselectable layer?
And do you want it to select the next layer down when it finds one?

Re: make layer unselectable?

Posted: Fri Sep 03, 2021 11:02 pm
by davoodice2
synthsin75 wrote: Fri Sep 03, 2021 5:52 pm
davoodice2 wrote: Fri Sep 03, 2021 8:03 am very interested! . now is it possible to change it to ignore locked layer and select behind layer?
And do you want it to select the next layer down when it finds one?
exactly!

Re: make layer unselectable?

Posted: Fri Sep 03, 2021 11:17 pm
by synthsin75
davoodice2 wrote: Fri Sep 03, 2021 11:02 pm
synthsin75 wrote: Fri Sep 03, 2021 5:52 pm And do you want it to select the next layer down when it finds one?
exactly!
If you want to go to the next layer down, including to the next group, you'll have to create a table of all the layers in the document, in layer window order.

I have a routine for that, called Recursive, in the Utility functions sections of my switch icons tool. You'll just have to find the clicked layer on that table of layers and select the next layer in the table.