Forum > macOS / Mac OS X
create window OS X
(1/1)
Key-Real:
I'm so far:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{$mode objfpc}{$H+}{$modeswitch objectivec1} uses gl, MacOSAll, CocoaAll; type { MyCallback } MyCallback = objcclass(NSObject) public procedure haltMenuEvent(sender: id); message 'haltMenuEvent:'; end; var pool : NSAutoreleasePool; filemenu : NSMenu; subitem : NSMenuItem; app : NSApplication; callback : MyCallback; MainWindow: NSWindow; MainView: NSView; R: NSRect; function NSStr(const s: AnsiString): NSString;begin if s='' then Result:=NSString.alloc.init else Result:=NSString.alloc.initWithCString(@s[1]);end; { MyCallback } procedure MyCallback.haltMenuEvent(sender:id);begin WriteLn('HALT!'); app.stop(self);end; procedure initMenus;var root : NSMenu; rootitem : NSMenuItem;begin root:=NSMenu.alloc.init; rootitem:=root.addItemWithTitle_action_keyEquivalent(NSStr(''), nil, NSStr('')); filemenu:=NSMenu.alloc.initWithTitle(NSStr('File')); rootitem.setSubmenu(filemenu); rootitem.setEnabled(true);subitem:=filemenu.addItemWithTitle_action_keyEquivalent(NSStr('Halt'), nil, NSStr('')); subitem.setEnabled(true); app.setMainMenu(root);end; procedure InitCallback;begin callback:=MyCallback.alloc; subitem.setAction(ObjCSelector(callback.haltMenuEvent)); subitem.setTarget(callback);end; begin pool:=NSAutoreleasePool.alloc.init; app:=NSApplication.sharedApplication; R.origin.x := 300.0; R.origin.y := 300.0; R.size.width := 300.0; R.size.height := 300.0; MainWindow := NSWindow.alloc.initWithContentRect_styleMask_backing_defer(R, NSTitledWindowMask or NSClosableWindowMask or NSMiniaturizableWindowMask or NSResizableWindowMask, NSBackingStoreBuffered, False); MainWindow.orderFrontRegardless; MainWindow.setTitle(NSSTR('Title')); R.origin.x := 0.0; R.origin.y := 0.0; MainView := NSView.alloc.initWithFrame(R); MainWindow.setContentView(MainView); initMenus; initCallback; app.run; pool.release;end.
Is it possible to do a moin loop like the:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---repeat updatemessages; // windows styleuntil true;
or is there only one option to go with callbacks and
app.run;
?
[Edited to add code tags - please see How to use the Forums.]
lucamar:
Please, use code tags ...
Navigation
[0] Message Index