Page 1 of 1

UI Alignments

Posted: Mon May 13, 2024 4:23 pm
by MehdiZangenehBar
Is it possible to align any control to the right side of the toolbar? it seems LM.GUI.ALIGN_RIGHT dosn't effect at all.
Also is it possible to change width of the button? It seems this one is also missed.

Code: Select all

-- **************************************************
-- General information about this script
-- **************************************************

ScriptName = "TestScript"

TestScript = {}

function TestScript:Name()
	return 'Name'
end

function TestScript:Version()
	return 'Version'
end

function TestScript:UILabel()
	return 'UILabel'
end

function TestScript:Creator()
	return 'Creator'
end

function TestScript:Description()
	return 'Description'
end


-- **************************************************
-- Is Relevant / Is Enabled
-- **************************************************

function TestScript:IsRelevant(moho)
	return true
end

function TestScript:IsEnabled(moho)
	return true
end

-- **************************************************
-- Events
-- **************************************************

function TestScript:OnMouseDown(moho, mouseEvent)
end

function TestScript:DoLayout(moho, layout)
	local button = LM.GUI.Button('Button', 0)
	layout:AddChild(button, LM.GUI.ALIGN_RIGHT, 0)
end

Re: UI Alignments

Posted: Sun May 26, 2024 12:33 am
by synthsin75
This works for my screen resolution, but if you change the size of the Moho window, you'd have to reselect the tool to update to the new window dimensions.

Code: Select all

function TestScript:DoLayout(moho, layout)
	local button = LM.GUI.Button('Button', 0)
	layout:AddPadding(moho.view:Width() + 300)
	layout:AddChild(button, LM.GUI.ALIGN_RIGHT, 0)
end
It's really using the workspace view dimensions, because Moho doesn't natively report the window size to the API.
This example is resolution dependent, so to really make it useful, you'd need to query the OS about the screen resolution and window size.
Makes aligning to the right fairly impractical, unless you just want to align to the right side of the workspace.

You make buttons smaller using negative padding. If you want to see a master class in this technique, check out Rai's Shapes Window tool: viewtopic.php?t=36508