下面的代码示例
import 'lobjc.so' as objc;
var NSObject = objc.NSClassFromString('NSObject');
var NSColor = objc.NSClassFromString('NSColor');
var NSWindow = objc.NSClassFromString('NSWindow');
var NSWindowController = objc.NSClassFromString('NSWindowController');
var NSApplication = objc.NSClassFromString('NSApplication');
@objc.protocol('NSWindowDelegate')
class WindowDelegate(NSObject) {
def windowDidResize_(var n) {
}
}
class WindowController(NSWindowController) {
}
@objc.protocol('NSApplicationDelegate')
class AppDelegate(NSObject) {
def applicationDidFinishLaunching_(var aNotification) {
self.window = NSWindow(
contentRect = objc.CGRectMake(10, 10, 800, 600),
styleMask = objc.NSWindowStyleMaskMiniaturizable |
objc.NSWindowStyleMaskTitled |
objc.NSWindowStyleMaskClosable |
objc.NSWindowStyleMaskResizable,
backing = objc.NSBackingStoreBuffered,
defer = false);
self.window.setTitle_("Hello,World!");
self.windowDelegate = WindowDelegate();
self.window.setDelegate_(self.windowDelegate);
self.window.setBackgroundColor_(NSColor.whiteColor());
self.windowController = WindowController(window=self.window);
self.windowController.showWindow_(self);
self.windowController.showWindow_(self.windowController);
}
def applicationShouldTerminateAfterLastWindowClosed_(var app) {
return true;
}
}
var delegate = AppDelegate();
var app = NSApplication.sharedApplication();
app.setDelegate_(delegate);
app.run();
更多例子可以看代码里的 example 目录。目前只有 2000 多行代码,欢迎大家帮忙测试和改进。
1
noli 2017-10-25 18:55:12 +08:00
精神可嘉,送你一波铜币,聊表敬意。
期待 有 lemon lang 的详细 tutorial 以及 feature |
2
xiubin 2017-10-26 10:14:36 +08:00
示例代码在哪里。。
|
3
forestyuan 2017-10-26 10:26:19 +08:00
开源吗?
|
4
pheyer 2017-10-26 14:31:47 +08:00
怎么调试?
|
5
zhicheng OP |