Page 1 of 1

How to set values for InsertTextParams

Posted: Sat Jul 25, 2015 7:17 am
by strider2000
I see that InsertText is deprecated and we should use the new method, but I don't know how to set the values for InsertTextParams and whether or not the fields in the struct have default values (ie do they all need to be explicitly set).
// The following method is deprecated, but remains for older scripts.
// Use the new void InsertText(int32 lineOffset, InsertTextParams *textParams) method instead
void InsertText(const char *text, const char *font, bool fill, bool stroke, bool groupTogether, bool centerH, int32 lineOffset);
Can anyone show me an example of how to properly invoke the new method using InsertTextParams? Thanks.

Re: How to set values for InsertTextParams

Posted: Sun Feb 10, 2019 7:33 am
by synthsin75
I know this is a really old post, but it's where I first landed trying to figure this out/remember it myself.

For adding text to a mesh layer:

Code: Select all

	local param = MOHO.MohoGlobals.InsertText
	param.Text:Set("Hello")
	moho:InsertText(param, 0)
For creating a new text layer:

Code: Select all

	local param = MOHO.MohoGlobals.InsertText
	param.Text:Set("Hello")
	param.OneFill = true
	param.MakeLayer = true --only works for moho:CreateTextObject() or text layer
	moho:CreateNewLayer(MOHO.LT_TEXT)
	moho:InsertText(param, 1000)
Invokes insert text dialog, populated with the setting set in param:

Code: Select all

	moho:CreateTextObject()
The param indexes and data types are listed here: http://mohoscripting.com/methods/85