From 4215ae70c63050248408270e4b604fef36a25de3 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Mon, 29 Sep 2008 02:17:34 +0000 Subject: [PATCH] Adds more classes and improves texteditor example git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@576 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../pascocoa/examples/texteditor/controller.pas | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bindings/pascocoa/examples/texteditor/controller.pas b/bindings/pascocoa/examples/texteditor/controller.pas index 77f1a81cd..a1d4dbce3 100644 --- a/bindings/pascocoa/examples/texteditor/controller.pas +++ b/bindings/pascocoa/examples/texteditor/controller.pas @@ -77,7 +77,9 @@ begin inherited Create; { Create objects } + OpenPanel := NSOpenPanel.openPanel; + SavePanel := NSSavePanel.savePanel; end; { Objective-c Methods } @@ -94,20 +96,31 @@ var begin { Show dialog } - if OpenPanel.runModal = NSFileHandlingPanelOKButton then + if SavePanel.runModal = NSFileHandlingPanelOKButton then begin { Now move the contents of the file to the edit control } FileContents := NSString.initWithContentsOfFile(OpenPanel.filename); - myView.TextField.setStringValue(CFStringRef(FileContents.Handle)); + FileContents.writeToFile_atomically(SavePanel.filename, False); end; end; class procedure TMyController.doSaveFile(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; +var + FileContents: NSString; begin + { Show dialog } + if OpenPanel.runModal = NSFileHandlingPanelOKButton then + begin + { Now move the contents of the edit control to the file } + + FileContents := NSString.CreateWithHandle(objc.id(myView.TextField.StringValue)); + + myView.TextField.setStringValue(CFStringRef(FileContents.Handle)); + end; end; class procedure TMyController.doSaveFileAs(_self: objc.id; _cmd: SEL;