Board index FlightGear Development Nasal

Canvas Event

Nasal is the scripting language of FlightGear.

Canvas Event

Postby clm76 » Sat Feb 23, 2019 12:06 pm

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: 204
Joined: Tue Oct 30, 2012 9:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2020.4.0
OS: Linux Mint 20.2

Re: Canvas Event

Postby Hooray » Sun Feb 24, 2019 5: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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Canvas Event

Postby clm76 » Tue Feb 26, 2019 6: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: 204
Joined: Tue Oct 30, 2012 9:18 pm
Location: France - LFOH
Callsign: F-GCLM
Version: 2020.4.0
OS: Linux Mint 20.2

Re: Canvas Event

Postby jsb » Sat Mar 09, 2019 11: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: 285
Joined: Sat Oct 25, 2014 9:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: Canvas Event

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

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


Return to Nasal

Who is online

Users browsing this forum: No registered users and 2 guests