Skinnable canvas window: Difference between revisions

Jump to navigation Jump to search
Line 16: Line 16:
sk.addSkin("/foo/osc2.png"));</syntaxhighlight>
sk.addSkin("/foo/osc2.png"));</syntaxhighlight>


=== listen_mouse_clicks: func(object, function) ===
=== listen_mouse_events: func(caller, Hots) ===
: creates the listener and binds the events to ''function(e)''. Also checks the {{key press |ctrl}} key: ''ctrl-click'' outputs the mouse coordinates.
: '''Hots''' as vector of hashes as:  <br />
'''object''' as the calling object.<br />
*  {type:"click",  x:<''x''>, y:<''y''>,  action:<''action''>, tol:<''tol''>, parms:<''parms''> }
'''function''' as the callback function.<br />
*  {type:"wheel", x:<''x''>, y:<''y''>,  action:<''action''>, tol:<''tol''> }
: e.g. <syntaxhighlight lang="nasal">var sk = canvas.skinnable.new([575,290]);
*  {type:"cursor", x:<''x''>, y:<''y''>, style:<''style''>, tol:<''tol''>, tip:<''tipText''> }
sk.addSkin("/foo/osc2.png"));
*  {type:"tip", x:<''x''>, y:<''y''>, text:<''tipText''>, tol:<''tol''> }
sk.listen_mouse_clicks(object:me, function:me.onClick);
: where  ''x'' and ''y'' are the local coords of the hotspot.
</syntaxhighlight>
::: ''action'' (as string) is a function. The event will call the '''''caller['action']''''' method.
::: ''tol'' is the tolerance, the hotspot radious.
::: ''parms'' (as vector, scalar or nil) will be passed to ''caller.action()'' as arguments.
::: ''style'' (as string) is the cursor style to be used over the hotspot.
::: ''tipText'' is the string to be shown over the hotspot. Use an empty string for none.
<br />
: e.g. (borrowed from Oscilloscope) <syntaxhighlight lang="nasal">var wheelHots = [
{type:'wheel', x:417, y:82, action:'set1Gain', tol:12 },
{type:'cursor', x:417, y:82, style:'hand',      tol:12,  tip:'Ch-1 Gain' },
{type:'click',  x:427, y:82, action:'set1Gain', tol:6 ,  parms:1  },
{type:'click',  x:403, y:82, action:'set1Gain', tol:6 ,  parms:-1 },...
        ];
me.sk.listen_mouse_events(caller:me, Hots:Hots);</syntaxhighlight>


== Members ==
== Members ==
229

edits

Navigation menu