Board index FlightGear Development Canvas

widgets.LineEdit constructor problem  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.

widgets.LineEdit constructor problem

Postby F-JJTH » Sat Nov 22, 2014 11:55 am

Hi,

I stopped to work on checkbox for now until it is possible to update them in live.
So I'm playing with the LineEdit widget and get some problem.

With the CheckBox and Label widget I used to write this code
Code: Select all
var my_cb = gui.widgets.CheckBox.new(me._scroll_content, style, {}).setText("Enable");
var my_label = gui.widgets.Label.new(me._scroll_content, style, {}).setText("# FGCom");

It works without problem.


However with the LineEdit widget this code doesn't work:
Code: Select all
var callsignField = gui.widgets.LineEdit.new(me._scroll_content, style, {}).setText("F-JJTH");


the console error is:
Nasal runtime error: Fatal error in method call: Can not convert to 'canvas.LayoutItem': not a derived hash
at /home/clement/fgfs/install/flightgear/fgdata/Nasal/canvas/gui/dialogs/GlobalMenu.nas, line 357
called from: /home/clement/fgfs/install/flightgear/fgdata/Nasal/canvas/gui/dialogs/GlobalMenu.nas, line 74
called from: /home/clement/fgfs/install/flightgear/fgdata/Nasal/canvas/gui/dialogs/GlobalMenu.nas, line 74
called from: /home/clement/fgfs/install/flightgear/fgdata/Nasal/canvas/gui/dialogs/GlobalMenu.nas, line 64


but this code works:
Code: Select all
var callsignField = gui.widgets.LineEdit.new(me._scroll_content, style, {});
callsignField.setText("F-JJTH");


Why it isn't possible to use the setText() method at initialization like I do with the CheckBox and Label widget ?

PS: I get the same problem with setMaxLength() and forced to use the same hack as setText()
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: widgets.LineEdit constructor problem

Postby F-JJTH » Sun Nov 23, 2014 8:40 pm

up ? :)
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am

Re: widgets.LineEdit constructor problem  

Postby TheTom » Sun Nov 23, 2014 10:37 pm

Should be fixed now :-)
TheTom
 
Posts: 321
Joined: Sun Oct 09, 2011 10:20 am

Re: widgets.LineEdit constructor problem

Postby Hooray » Mon Nov 24, 2014 9:58 am

@F-JJTH: Explanation at: http://wiki.flightgear.org/Object_Orien ... :_Chaining

(this works the same way, no matter if it's C++ or Nasal: to make a method chain-able, you need to return a reference/pointer of the object (this/me))
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: widgets.LineEdit constructor problem

Postby F-JJTH » Wed Nov 26, 2014 12:52 am

Thanks you guys !
User avatar
F-JJTH
 
Posts: 697
Joined: Fri Sep 09, 2011 11:02 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest