How to set values for InsertTextParams

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
strider2000
Posts: 506
Joined: Sat Mar 07, 2015 5:14 pm
Contact:

How to set values for InsertTextParams

Post 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.
User avatar
synthsin75
Posts: 9968
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: How to set values for InsertTextParams

Post 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
Post Reply