"""
To compile:
cobra -c -t:winexe -r:System.Windows.Forms winforms.cobra
To run:
winforms
Or leave out the "-c" to compile and run in one shot.
Recommended reading:
Programming Microsoft Windows Forms
by Charles Petzold
Cobra tips:
* Combine enums: AnchorStyle(Left, Right)
* Hook up events: listen someObj.someEvent, ref .myMethod
"""
use System.Windows.Forms
class MyForm
inherits Form
def init
.text = 'Click Me'
listen .click, ref .handleClick
def handleClick(sender as Object, args as EventArgs)
MessageBox.show('You clicked me!', 'Click')
class Program
def main is shared
Application.run(MyForm())
Note that the Petzold book has extensive information on how to build GUIs by hand and take advantage of anchors, docking, autosizing, etc.
The current Cobra weakness that I know of is that if in the "listen" statement you try to "ref" an overloaded method you will get a not-so-helpful error message. If you break the overloading by changing the method name that handles the event then all is well.