How to create the image on a field dialogbox?

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
maxic
Posts: 64
Joined: Wed Sep 22, 2004 8:24 am
Location: Moscow, Russian Federation
Contact:

How to create the image on a field dialogbox?

Post by maxic »

How to create the image on a field dialogbox?
myles
Posts: 821
Joined: Sat Aug 21, 2004 3:32 am
Location: Australia, Victoria, Morwell
Contact:

Re: How to create the image on a field dialogbox?

Post by myles »

maxic wrote:How to create the image on a field dialogbox?
I assume you are talking about a preview image, such as the star shape shown here:
Image

See the sample scripts lm_star.lua or lm_polygon.lua for details.

As I understand it, you need to add a mesh preview in your dialog definition:

Code: Select all

	d.preview = MOHO.MeshPreview(200, 200)
	l:AddChild(d.preview)
Add an update function that redraws your shape in the preview:

Code: Select all

function LM_PolygonDialog:UpdatePreview()
	local mesh = self.preview:Mesh()
	mesh:Clear()

	local numPoints = self.numPoints:IntValue()
	numPoints = LM.Clamp(numPoints, 3, 20)

	LM_Polygon:BuildPolygon(mesh, numPoints)
	self.preview:CreateShape(true)
	self.preview:Refresh()
end
and call the update function at the appropriate times (when updating widgets, handling messages, etc.):

Code: Select all

		self:UpdatePreview()
Regards, Myles.
User avatar
maxic
Posts: 64
Joined: Wed Sep 22, 2004 8:24 am
Location: Moscow, Russian Federation
Contact:

Thanks, it I too looked in examples

Post by maxic »

It is necessary BITMAP
User avatar
Lost Marble
Site Admin
Posts: 2347
Joined: Tue Aug 03, 2004 6:02 pm
Location: Scotts Valley, California, USA
Contact:

Post by Lost Marble »

Not possible at this time.
User avatar
maxic
Posts: 64
Joined: Wed Sep 22, 2004 8:24 am
Location: Moscow, Russian Federation
Contact:

Post by maxic »

And in the future it is planned? :?:
User avatar
Lost Marble
Site Admin
Posts: 2347
Joined: Tue Aug 03, 2004 6:02 pm
Location: Scotts Valley, California, USA
Contact:

Post by Lost Marble »

maxic wrote:And in the future it is planned? :?:
Maybe. There are certainly lots of ways to imrpove the Lua scripting capabilities.
Post Reply