if that's your only code, you cannot simply pass
size[0] like that to the .set() method (unless size happens to be a vector that points to the corresponding properties...), you need to specify the property path here, i.e. based on the property browser - like I suggested earlier.
Overall, I wouldn't focus too much on those areas where you still find yourself having open questions - currently, most people here are busy with other stuff, which is why there's been so little feedback probably, but that will certainly change after the release. So, I'd suggest to continue with stuff that you know how to implement, or simply work through some of the Nasal/Canvas tutorials in the meantime.
Like previously suggested, many questions can be answered by playing around with the Nasal console, some canvas snippets and looking at the canvas textures in the property tree using the property browser.
In general, it's also helpful not just to post some snippet of code, but specify exactly the nature of the problem -otherwise, we need to guess what's going on - i.e. it isn't clear if you're getting a warning, error - or if everything compiles correctly, and you are just not getting the expected behavior ?
If that's the case, your code is at least syntactically valid and you are probably working with wrong assumptions, which can be resolved by taking things more slowly and using the Nasal console to play with tiny self-contained snippets first, to ensure that you actually understand the fundamentals.
My previous posting(s) were intended to help with that: 1) take the Nasal console, 2) paste the code, 3) read through it, 4) run it - and see if it makes sense to you or not.
I have downloaded your latest code and will try to have a look and report back soon.
@anybody else, see:
http://pastebin.com/yrLu9j7WEDIT: Actually, your code looks much better/cleaner than your questions would have suggested, playing around first with the about dialog was a good idea - and it's even OOP-style to a fair degree, good job!
EDIT2: I think your use of variables like
me.Me could be causing some confusion, it's certainly confusing me!
EDIT3: Some more feedback:
- your resizer method is referring to variables that don't exist - try to look up the property paths that you need, or simply look at $FG_ROOT/Nasal/canvas/gui.nas
- which tells you how width and height are set up by the canvas.Window.new() constructor: https://gitorious.org/fg/fgdata/blobs/m ... .nas#line5
- as you can see, the property paths are "size[0]" and "size[1]" - https://gitorious.org/fg/fgdata/blobs/m ... nas#line13
- so to change the size of the dialog, you only need to set these properties on the WINDOW/dialog handle, which is "dlg" NOT root
- BTW: try to get rid of the me.Me notation you are using - it's VERY confusing and error-prone, you would typically set up a temporary variable and then return that from the constructor
- see this tutorial for a very short and simple explanation: http://wiki.flightgear.org/Object_Orien ... nstructors
(the whole tutorial is pretty good and could simplify your work quite a bit, especially once you look at the underlying code in $FG_ROOT/Nasal/canvas/gui.nas)
EDIT4: Here's a slightly-edited version of your file, that 1) gets rid of the me.Me pattern you were using - and 2) which fixes your resize callback:
http://codepad.org/7jvJYJ0iIf you want to resize something else, you merely need to change the instance variable, i.e. use "me.B1", "bar" or "dlg" instead of root.
Instead of the colored boxes, you may want to use real buttons, see gui.nas - we also have a tooltip class, that shows explanations for buttons, see the canvas directory
Looking at your code, I take back my earlier comments - you seem to have worked through quite a number of tutorials already, it just wasn't clear by your questions - but your code makes it obvious now, well done!
EDIT5: I now also understand your addhandler() issue: You should have read my previous responses, you were making exactly the mistake that I tried to explain: Whenever you have a complex expression, you cannot simple specify it inline as an anonymous function, you MUST wrap it inside a real func expression, or a standalone function - your dum[0] workaround is a neat hack, but unnecessary:
- Code: Select all
sidebar["start"].addhandler('click', dum[0] = func plot["line"].start());
becomes this, where you wrap your expressions in a func {} block
- Code: Select all
sidebar["start"].addhandler('click',
func() {
plot["line"].start();
}
);
The empty argument list strictly isn't required for functions that do not have any/named arguments, so you could also just use func {} here instead of func() {}.
having a single func expression without curly braces will only work for very simple expressions, for example this should work (no dum[0] needed here):
- Code: Select all
menubar["chgtxt"].addhandler('click',
func
menubar["title"].settitle("My.Oh.My")
);
(whitespaces/indentation not relevant, just added for clarity)
Here's an updated version of your code, without the dum[0] workaround:
http://codepad.org/VfdtXWYkEDIT6: Here's all your code as a Nasal submodule:
http://codepad.org/oAdeFu0QTo download the code directly, open
http://codepad.org/oAdeFu0Q/raw.txt and save it as fgplot2.nas in $FG_ROOT/Nasal/fgplot2/
http://wiki.flightgear.org/Creating_new ... ub_modules