Board index FlightGear Development Canvas

What is My id ? canvas.Window.new()  Topic is solved

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

What is My id ? canvas.Window.new()

Postby kuifje09 » Tue Jul 30, 2013 7:14 pm

Hello, I ran into the next question. I created a window, canvas.Window.new() ans so on for the canvas etc. But now I want to know what is my id,
or how to access the tf.t values, in fact 2 questions, becaus the id leads to more properties...
I know it is in /sim/gui/canvas/window[?]/tf/t[|1] but how can I find my id which is needed to get to window[id].*
I could not find it in some docs? wrong docs I must have read... And tried almost anything I could guess about. but no luck sofar.

If someone knows howto find a way to know who I am, ( the window ) I would be very pleased.
I do not mean to go through the property browser, but by some nasal command. i.e.

Mywindow = canvas.Window.new();
MyId = MyWindow.id;

such form or like that...

Thanks in advance.
kuifje09
 
Posts: 579
Joined: Tue May 17, 2011 8:51 pm

Re: What is My id ? canvas.Window.new()  

Postby kuifje09 » Tue Jul 30, 2013 8:07 pm

Well, found a kind of solution. Went trough the source and saw this,
m.setInt("content-size[0]", size[0]);
m.setInt("content-size[1]", size[1]);
Then I tried getInt and get, it was get... Now I can continue again.... also for other property members.
kuifje09
 
Posts: 579
Joined: Tue May 17, 2011 8:51 pm

Re: What is My id ? canvas.Window.new()

Postby Hooray » Tue Jul 30, 2013 10:00 pm

Code: Select all
canvas.get( cmdarg() );


you can simple use this to get a handle to the active canvas
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: 11427
Joined: Tue Mar 25, 2008 8:40 am

Re: What is My id ? canvas.Window.new()

Postby TheTom » Wed Jul 31, 2013 2:33 am

Hooray wrote in Tue Jul 30, 2013 10:00 pm:
Code: Select all
canvas.get( cmdarg() );

This only works within xml dialogues...

For windows window.get("id") should work. (I'm on vacation, so I can not check it...)
TheTom
 
Posts: 321
Joined: Sun Oct 09, 2011 10:20 am

Re: What is My id ? canvas.Window.new()

Postby kuifje09 » Wed Jul 31, 2013 3:09 pm

If by example, this works in any case when create a window from nasal.
Code: Select all
      me.dlg = canvas.Window.new([w,h]);
#This is my id
      me.id = me.dlg.get("id");
      print("My id is :"~me.id);
#This is my property path
      me.prop = "/sim/gui/canvas/window["~me.id~"]";
      print("My property path : "~me.prop);

Maybe there is another shortcut, but this clearly shows what is going on.
kuifje09
 
Posts: 579
Joined: Tue May 17, 2011 8:51 pm

Re: What is My id ? canvas.Window.new()

Postby F-JYL » Sun Jan 12, 2014 4:50 am

Does not work if you create a window with the id :
Code: Select all
var wnd = canvas.Window.new([400,400],"type",55);
var id = wnd.get("id");
print(id);
print (getprop("/sim/gui/canvas/window["~id~"]/id"));

In this case the property path is using the last index of the table /sim/gui/canvas/window
F-JYL
 
Posts: 54
Joined: Mon Mar 11, 2013 8:34 pm
Callsign: F-JYL
Version: git
OS: Ubuntu 13.10


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest