Board index FlightGear Development Nasal

Canvas Event

Nasal is the scripting language of FlightGear.

Canvas Event

Postby clm76 » Sat Feb 23, 2019 11:06 am

Hi,

In the wiki "Canvas Event Handling" -> "Example Code" we can see :
Code: Select all
# Canvas GUI demo
#
#  Shows an icon in the top-right corner which upon click opens a simple window
#

var dlg = canvas.Window.new([32,32]);
dlg.setInt("tf/t[1]", 4)
   .setInt("right", 4);
...

Where is defined the function "setInt" and its params "tf/tf[1]", "right" ... and what are the others params ?
clm76
 
Posts: 148
Joined: Tue Oct 30, 2012 8:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2018.3.0
OS: Linux Mint 18.3

Re: Canvas Event

Postby Hooray » Sun Feb 24, 2019 4:35 pm

setInt() is a general setter, the tf stuff is the transformation matrix (open the property browser to see for yourself), the 2nd line is using method chaining, to access the previously returned note and set the "right" variable to 4
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11312
Joined: Tue Mar 25, 2008 8:40 am

Re: Canvas Event

Postby clm76 » Tue Feb 26, 2019 5:08 pm

the tf stuff is the transformation matrix (open the property browser to see for yourself), the 2nd line is using method chaining, to access the previously returned note and set the "right" variable to 4

Thanks for your reply.

setInt() is a general setter

Does "setInt()" mean "setInteger" or is it a different function?
clm76
 
Posts: 148
Joined: Tue Oct 30, 2012 8:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2018.3.0
OS: Linux Mint 18.3

Re: Canvas Event

Postby jsb » Sat Mar 09, 2019 10:24 pm

IIRC setInt is defined in propertyElement which is a base class for many canvas elements. It sets the property named by the first argument to the integer value given by the second argument.
jsb
 
Posts: 219
Joined: Sat Oct 25, 2014 8:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: Canvas Event

Postby clm76 » Tue Mar 12, 2019 6:42 am

Thanks jsb, it's better in my mind now ! 8)
clm76
 
Posts: 148
Joined: Tue Oct 30, 2012 8:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2018.3.0
OS: Linux Mint 18.3


Return to Nasal

Who is online

Users browsing this forum: No registered users and 2 guests