Skinnable canvas window: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 6: | Line 6: | ||
'''size''' mandatory as [''width, height''] vector, the window dimension.<br /> | '''size''' mandatory as [''width, height''] vector, the window dimension.<br /> | ||
'''title''' optional as string , the window title. Empty by default.<br /> | '''title''' optional as string , the window title. Empty by default.<br /> | ||
: e.g. < | : e.g. <syntaxhighlight lang="nasal"> var sk = canvas.skinnable.new([575,290]);</syntaxhighlight> | ||
== Methods == | == Methods == | ||
Line 13: | Line 13: | ||
: loads the image file and creates Canvas Image element. | : loads the image file and creates Canvas Image element. | ||
'''filename''' as the absolute file path. The file must be a .png or a .jpg image. | '''filename''' as the absolute file path. The file must be a .png or a .jpg image. | ||
: e.g. < | : e.g. <syntaxhighlight lang="nasal">var sk = canvas.skinnable.new([575,290]); | ||
sk.addSkin("/foo/osc2.png"));</syntaxhighlight> | |||
=== listen_mouse_clicks: func(object, function) === | === listen_mouse_clicks: func(object, function) === | ||
Line 20: | Line 20: | ||
'''object''' as the calling object.<br /> | '''object''' as the calling object.<br /> | ||
'''function''' as the callback function.<br /> | '''function''' as the callback function.<br /> | ||
: e.g. <syntaxhighlight lang="nasal">sk.addSkin("/foo/osc2.png")); | : e.g. <syntaxhighlight lang="nasal">var sk = canvas.skinnable.new([575,290]); | ||
sk.addSkin("/foo/osc2.png")); | |||
sk.listen_mouse_clicks(object:me, function:me.onClick); | |||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 21:07, 1 March 2018
The FlightGear forum has a subforum related to: Canvas |
skinnable.nas implements the skinnable class.
Constructor
new: func(size,title)
size mandatory as [width, height] vector, the window dimension.
title optional as string , the window title. Empty by default.
- e.g.
var sk = canvas.skinnable.new([575,290]);
Methods
Skinnable objects includes 2 methods:
addSkin: func(filename)
- loads the image file and creates Canvas Image element.
filename as the absolute file path. The file must be a .png or a .jpg image.
- e.g.
var sk = canvas.skinnable.new([575,290]); sk.addSkin("/foo/osc2.png"));
listen_mouse_clicks: func(object, function)
- creates the listener and binds the events to function(e).
object as the calling object.
function as the callback function.
- e.g.
var sk = canvas.skinnable.new([575,290]); sk.addSkin("/foo/osc2.png")); sk.listen_mouse_clicks(object:me, function:me.onClick);