Thanks to user "callisto" for contributing GTK# docs including screenshots, example code for various widgets, layouts, menus, etc. It starts here:
http://cobra-language.com/trac/cobra/wiki/GtkLibrary
Forums
New GTK# docs
4 posts
• Page 1 of 1
Re: New GTK# docs
Thanks Charles - I hope the material is useful. (You beat me to the announcement!)
A cobra question: is it possible to write something like:
i.e. pass a reference to an anonymous method? (I've tried creating sigs and local variables, but can't find a combination that works.) This would save a lot of boilerplate code, constructing single-use methods, just to get a name to reference.
The wiki entry for Listen, http://cobra-language.com/trac/cobra/wiki/Listen, ends with "# Todo example using closure/anonymous method", but I'm not sure that is referring to what I need.
A cobra question: is it possible to write something like:
listen button.clicked, ref do(obj,e)=Application.quit # this doesn't work!
i.e. pass a reference to an anonymous method? (I've tried creating sigs and local variables, but can't find a combination that works.) This would save a lot of boilerplate code, constructing single-use methods, just to get a name to reference.
The wiki entry for Listen, http://cobra-language.com/trac/cobra/wiki/Listen, ends with "# Todo example using closure/anonymous method", but I'm not sure that is referring to what I need.
- callisto
- Posts: 10
Re: New GTK# docs
Good question.
The "do(args)=expr" form is only for expressions and is suitable when the return value is of interest and will be used. In the case where you need statements, they go on the next line indented and you can have as many statements as you like.
The type for "args" is currently required because Cobra is not yet as good as it should be about inferring the arg types. That will be improved in the future.
You need the "ref" keyword to refer to a named method so that it is not invoked. You never need "ref" and "do" at the same time--just one of them.
listen button.clicked, do(sender, args as EventArgs)
print 'Quitting'
Application.quit
The "do(args)=expr" form is only for expressions and is suitable when the return value is of interest and will be used. In the case where you need statements, they go on the next line indented and you can have as many statements as you like.
The type for "args" is currently required because Cobra is not yet as good as it should be about inferring the arg types. That will be improved in the future.
You need the "ref" keyword to refer to a named method so that it is not invoked. You never need "ref" and "do" at the same time--just one of them.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: New GTK# docs
Charles wrote:The "do(args)=expr" form is only for expressions and is suitable when the return value is of interest and will be used. In the case where you need statements, they go on the next line indented and you can have as many statements as you like.
Thanks, that's a helpful clarification. I've got a few examples working now, and, in the right place, the anonymous methods are a convenient simplification.
- callisto
- Posts: 10
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 50 guests