Skinnable canvas window: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
{{Template:Canvas Navigation}}
{{Template:Canvas Navigation}}


skinnable.nas implements the skinnable class.  
skinnable.nas implements the ''skinnable'' class. It inherits from ''canvas''.
== Constructor ==
== Constructor ==
=== new: func(size,title)  ===
=== new: func(size,title)  ===

Revision as of 21:16, 1 March 2018


skinnable.nas implements the skinnable class. It inherits from canvas.

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). Also checks the ctrl key: ctrl-click outputs the mouse coordinates.

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);