You've already forked lazarus-ccr
Improves pascocoa and texteditor example
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@586 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -29,6 +29,7 @@ type
|
|||||||
class procedure doClose(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; {$ifndef VER2_2_2}static;{$endif}
|
class procedure doClose(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||||
class procedure doOpenFile(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; {$ifndef VER2_2_2}static;{$endif}
|
class procedure doOpenFile(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||||
class procedure doSaveFile(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; {$ifndef VER2_2_2}static;{$endif}
|
class procedure doSaveFile(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||||
|
class procedure doSaveAsFile(_self: objc.id; _cmd: SEL; sender: objc.id); cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||||
class function applicationShouldTerminateAfterLastWindowClosed(_self: objc.id;
|
class function applicationShouldTerminateAfterLastWindowClosed(_self: objc.id;
|
||||||
_cmd: SEL; theApplication: objc.id): cbool; cdecl; {$ifndef VER2_2_2}static;{$endif}
|
_cmd: SEL; theApplication: objc.id): cbool; cdecl; {$ifndef VER2_2_2}static;{$endif}
|
||||||
end;
|
end;
|
||||||
@ -37,6 +38,7 @@ const
|
|||||||
Str_doClose = 'doClose:';
|
Str_doClose = 'doClose:';
|
||||||
Str_doOpenFile = 'doOpenFile:';
|
Str_doOpenFile = 'doOpenFile:';
|
||||||
Str_doSaveFile = 'doSaveFile:';
|
Str_doSaveFile = 'doSaveFile:';
|
||||||
|
Str_doSaveAsFile = 'doSaveAsFile:';
|
||||||
Str_applicationShouldTerminateAfterLastWindowClosed = 'applicationShouldTerminateAfterLastWindowClosed:';
|
Str_applicationShouldTerminateAfterLastWindowClosed = 'applicationShouldTerminateAfterLastWindowClosed:';
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -46,7 +48,7 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses view;
|
uses view, model;
|
||||||
|
|
||||||
{ TMyController }
|
{ TMyController }
|
||||||
|
|
||||||
@ -64,6 +66,7 @@ begin
|
|||||||
AddMethod(Str_doClose, 'v@:@', Pointer(doClose));
|
AddMethod(Str_doClose, 'v@:@', Pointer(doClose));
|
||||||
AddMethod(Str_doOpenFile, 'v@:@', Pointer(doOpenFile));
|
AddMethod(Str_doOpenFile, 'v@:@', Pointer(doOpenFile));
|
||||||
AddMethod(Str_doSaveFile, 'v@:@', Pointer(doSaveFile));
|
AddMethod(Str_doSaveFile, 'v@:@', Pointer(doSaveFile));
|
||||||
|
AddMethod(Str_doSaveAsFile, 'v@:@', Pointer(doSaveAsFile));
|
||||||
AddMethod(Str_applicationShouldTerminateAfterLastWindowClosed, 'B@:@',
|
AddMethod(Str_applicationShouldTerminateAfterLastWindowClosed, 'B@:@',
|
||||||
Pointer(applicationShouldTerminateAfterLastWindowClosed));
|
Pointer(applicationShouldTerminateAfterLastWindowClosed));
|
||||||
end;
|
end;
|
||||||
@ -97,9 +100,11 @@ begin
|
|||||||
|
|
||||||
if OpenPanel.runModal = NSFileHandlingPanelOKButton then
|
if OpenPanel.runModal = NSFileHandlingPanelOKButton then
|
||||||
begin
|
begin
|
||||||
|
CFStringGetPascalString(OpenPanel.filename, @myModel.DocumentName, 255, kCFStringEncodingUTF8);
|
||||||
|
|
||||||
{ Now move the contents of the edit control to the file }
|
{ Now move the contents of the edit control to the file }
|
||||||
|
|
||||||
FileContents := NSString.CreateWithHandle(objc.id(myView.TextField.StringValue));
|
FileContents := NSString.initWithContentsOfFile(OpenPanel.filename);
|
||||||
|
|
||||||
myView.TextField.setStringValue(CFStringRef(FileContents.Handle));
|
myView.TextField.setStringValue(CFStringRef(FileContents.Handle));
|
||||||
end;
|
end;
|
||||||
@ -109,16 +114,34 @@ class procedure TMyController.doSaveFile(_self: objc.id; _cmd: SEL;
|
|||||||
sender: objc.id); cdecl;
|
sender: objc.id); cdecl;
|
||||||
var
|
var
|
||||||
FileContents: NSString;
|
FileContents: NSString;
|
||||||
|
begin
|
||||||
|
if myModel.DocumentName = Str_Untitled then doSaveAsFile(_self, _cmd, sender)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
{ Now move the contents of the file to the edit control }
|
||||||
|
|
||||||
|
FileContents := NSString.CreateWithHandle(objc.id(myView.TextField.StringValue));
|
||||||
|
|
||||||
|
FileContents.writeToFile_atomically(CFStringCreateWithPascalString(nil, myModel.DocumentName, kCFStringEncodingUTF8), False);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class procedure TMyController.doSaveAsFile(_self: objc.id; _cmd: SEL;
|
||||||
|
sender: objc.id); cdecl;
|
||||||
|
var
|
||||||
|
FileContents: NSString;
|
||||||
begin
|
begin
|
||||||
{ Show dialog }
|
{ Show dialog }
|
||||||
|
|
||||||
if SavePanel.runModal = NSFileHandlingPanelOKButton then
|
if SavePanel.runModal = NSFileHandlingPanelOKButton then
|
||||||
begin
|
begin
|
||||||
|
CFStringGetPascalString(SavePanel.filename, @myModel.DocumentName, 255, kCFStringEncodingUTF8);
|
||||||
|
|
||||||
{ Now move the contents of the file to the edit control }
|
{ Now move the contents of the file to the edit control }
|
||||||
|
|
||||||
FileContents := NSString.initWithContentsOfFile(OpenPanel.filename);
|
FileContents := NSString.CreateWithHandle(objc.id(myView.TextField.StringValue));
|
||||||
|
|
||||||
FileContents.writeToFile_atomically(SavePanel.filename, False);
|
FileContents.writeToFile_atomically(CFStringCreateWithPascalString(nil, myModel.DocumentName, kCFStringEncodingUTF8), False);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -29,9 +29,13 @@ type
|
|||||||
{ Routines and variables for program resources }
|
{ Routines and variables for program resources }
|
||||||
imgOpen, imgSave, imgClose: NSImage;
|
imgOpen, imgSave, imgClose: NSImage;
|
||||||
ResourcesDir: string;
|
ResourcesDir: string;
|
||||||
|
DocumentName: shortstring;
|
||||||
constructor Create;
|
constructor Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
const
|
||||||
|
Str_Untitled = 'Untitled /1';
|
||||||
|
|
||||||
var
|
var
|
||||||
myModel: TMyModel;
|
myModel: TMyModel;
|
||||||
|
|
||||||
@ -74,6 +78,8 @@ begin
|
|||||||
ResourcesDir := GetResourcesDir;
|
ResourcesDir := GetResourcesDir;
|
||||||
|
|
||||||
LoadImages;
|
LoadImages;
|
||||||
|
|
||||||
|
DocumentName := Str_Untitled;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<General>
|
<General>
|
||||||
<MainUnit Value="0"/>
|
<MainUnit Value="0"/>
|
||||||
<TargetFileExt Value=""/>
|
<TargetFileExt Value=""/>
|
||||||
<ActiveEditorIndexAtStart Value="1"/>
|
<ActiveEditorIndexAtStart Value="7"/>
|
||||||
</General>
|
</General>
|
||||||
<VersionInfo>
|
<VersionInfo>
|
||||||
<ProjectVersion Value=""/>
|
<ProjectVersion Value=""/>
|
||||||
@ -38,47 +38,47 @@
|
|||||||
<CursorPos X="9" Y="15"/>
|
<CursorPos X="9" Y="15"/>
|
||||||
<TopLine Value="1"/>
|
<TopLine Value="1"/>
|
||||||
<EditorIndex Value="0"/>
|
<EditorIndex Value="0"/>
|
||||||
<UsageCount Value="37"/>
|
<UsageCount Value="38"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
<Filename Value="model.pas"/>
|
<Filename Value="model.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="model"/>
|
<UnitName Value="model"/>
|
||||||
<CursorPos X="1" Y="4"/>
|
<CursorPos X="24" Y="32"/>
|
||||||
<TopLine Value="1"/>
|
<TopLine Value="27"/>
|
||||||
<EditorIndex Value="5"/>
|
<EditorIndex Value="5"/>
|
||||||
<UsageCount Value="37"/>
|
<UsageCount Value="38"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
<Unit2>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="view"/>
|
<UnitName Value="view"/>
|
||||||
<CursorPos X="1" Y="221"/>
|
<CursorPos X="49" Y="158"/>
|
||||||
<TopLine Value="74"/>
|
<TopLine Value="146"/>
|
||||||
<EditorIndex Value="7"/>
|
<EditorIndex Value="7"/>
|
||||||
<UsageCount Value="37"/>
|
<UsageCount Value="38"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit2>
|
</Unit2>
|
||||||
<Unit3>
|
<Unit3>
|
||||||
<Filename Value="controller.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="controller"/>
|
<UnitName Value="controller"/>
|
||||||
<CursorPos X="19" Y="98"/>
|
<CursorPos X="1" Y="145"/>
|
||||||
<TopLine Value="85"/>
|
<TopLine Value="130"/>
|
||||||
<EditorIndex Value="6"/>
|
<EditorIndex Value="6"/>
|
||||||
<UsageCount Value="37"/>
|
<UsageCount Value="38"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit3>
|
</Unit3>
|
||||||
<Unit4>
|
<Unit4>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="mytoolbar.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="mytoolbar"/>
|
<UnitName Value="mytoolbar"/>
|
||||||
<CursorPos X="51" Y="126"/>
|
<CursorPos X="28" Y="123"/>
|
||||||
<TopLine Value="115"/>
|
<TopLine Value="107"/>
|
||||||
<EditorIndex Value="1"/>
|
<EditorIndex Value="1"/>
|
||||||
<UsageCount Value="32"/>
|
<UsageCount Value="33"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit4>
|
</Unit4>
|
||||||
<Unit5>
|
<Unit5>
|
||||||
@ -115,7 +115,7 @@
|
|||||||
<CursorPos X="13" Y="60"/>
|
<CursorPos X="13" Y="60"/>
|
||||||
<TopLine Value="46"/>
|
<TopLine Value="46"/>
|
||||||
<EditorIndex Value="3"/>
|
<EditorIndex Value="3"/>
|
||||||
<UsageCount Value="11"/>
|
<UsageCount Value="12"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
</Unit9>
|
</Unit9>
|
||||||
<Unit10>
|
<Unit10>
|
||||||
@ -136,123 +136,123 @@
|
|||||||
<JumpHistory Count="30" HistoryIndex="29">
|
<JumpHistory Count="30" HistoryIndex="29">
|
||||||
<Position1>
|
<Position1>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="mytoolbar.pas"/>
|
||||||
<Caret Line="76" Column="1" TopLine="64"/>
|
<Caret Line="65" Column="1" TopLine="58"/>
|
||||||
</Position1>
|
</Position1>
|
||||||
<Position2>
|
<Position2>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="mytoolbar.pas"/>
|
||||||
<Caret Line="78" Column="1" TopLine="66"/>
|
<Caret Line="20" Column="34" TopLine="8"/>
|
||||||
</Position2>
|
</Position2>
|
||||||
<Position3>
|
<Position3>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="mytoolbar.pas"/>
|
||||||
<Caret Line="72" Column="1" TopLine="67"/>
|
<Caret Line="37" Column="22" TopLine="28"/>
|
||||||
</Position3>
|
</Position3>
|
||||||
<Position4>
|
<Position4>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="74" Column="92" TopLine="61"/>
|
<Caret Line="99" Column="12" TopLine="80"/>
|
||||||
</Position4>
|
</Position4>
|
||||||
<Position5>
|
<Position5>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="8" Column="12" TopLine="1"/>
|
<Caret Line="108" Column="1" TopLine="85"/>
|
||||||
</Position5>
|
</Position5>
|
||||||
<Position6>
|
<Position6>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="126" Column="30" TopLine="115"/>
|
<Caret Line="20" Column="22" TopLine="9"/>
|
||||||
</Position6>
|
</Position6>
|
||||||
<Position7>
|
<Position7>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="21" Column="55" TopLine="2"/>
|
<Caret Line="178" Column="5" TopLine="155"/>
|
||||||
</Position7>
|
</Position7>
|
||||||
<Position8>
|
<Position8>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="101" Column="111" TopLine="92"/>
|
<Caret Line="181" Column="5" TopLine="158"/>
|
||||||
</Position8>
|
</Position8>
|
||||||
<Position9>
|
<Position9>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="75" Column="5" TopLine="52"/>
|
<Caret Line="23" Column="27" TopLine="13"/>
|
||||||
</Position9>
|
</Position9>
|
||||||
<Position10>
|
<Position10>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="101" Column="20" TopLine="90"/>
|
<Caret Line="219" Column="1" TopLine="210"/>
|
||||||
</Position10>
|
</Position10>
|
||||||
<Position11>
|
<Position11>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="102" Column="13" TopLine="89"/>
|
<Caret Line="23" Column="8" TopLine="14"/>
|
||||||
</Position11>
|
</Position11>
|
||||||
<Position12>
|
<Position12>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="65" Column="1" TopLine="58"/>
|
<Caret Line="218" Column="1" TopLine="209"/>
|
||||||
</Position12>
|
</Position12>
|
||||||
<Position13>
|
<Position13>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="20" Column="34" TopLine="8"/>
|
<Caret Line="131" Column="1" TopLine="114"/>
|
||||||
</Position13>
|
</Position13>
|
||||||
<Position14>
|
<Position14>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="37" Column="22" TopLine="28"/>
|
<Caret Line="116" Column="44" TopLine="104"/>
|
||||||
</Position14>
|
</Position14>
|
||||||
<Position15>
|
<Position15>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="99" Column="12" TopLine="80"/>
|
<Caret Line="192" Column="35" TopLine="180"/>
|
||||||
</Position15>
|
</Position15>
|
||||||
<Position16>
|
<Position16>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="108" Column="1" TopLine="85"/>
|
<Caret Line="74" Column="15" TopLine="59"/>
|
||||||
</Position16>
|
</Position16>
|
||||||
<Position17>
|
<Position17>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="../../../objc/objc.pas"/>
|
||||||
<Caret Line="20" Column="22" TopLine="9"/>
|
<Caret Line="27" Column="12" TopLine="19"/>
|
||||||
</Position17>
|
</Position17>
|
||||||
<Position18>
|
<Position18>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="mytoolbar.pas"/>
|
||||||
<Caret Line="178" Column="5" TopLine="155"/>
|
<Caret Line="149" Column="9" TopLine="134"/>
|
||||||
</Position18>
|
</Position18>
|
||||||
<Position19>
|
<Position19>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="181" Column="5" TopLine="158"/>
|
<Caret Line="218" Column="77" TopLine="200"/>
|
||||||
</Position19>
|
</Position19>
|
||||||
<Position20>
|
<Position20>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="23" Column="27" TopLine="13"/>
|
<Caret Line="132" Column="5" TopLine="109"/>
|
||||||
</Position20>
|
</Position20>
|
||||||
<Position21>
|
<Position21>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="219" Column="1" TopLine="210"/>
|
<Caret Line="108" Column="1" TopLine="94"/>
|
||||||
</Position21>
|
</Position21>
|
||||||
<Position22>
|
<Position22>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="23" Column="8" TopLine="14"/>
|
<Caret Line="51" Column="17" TopLine="39"/>
|
||||||
</Position22>
|
</Position22>
|
||||||
<Position23>
|
<Position23>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="218" Column="1" TopLine="209"/>
|
<Caret Line="123" Column="35" TopLine="118"/>
|
||||||
</Position23>
|
</Position23>
|
||||||
<Position24>
|
<Position24>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="131" Column="1" TopLine="114"/>
|
<Caret Line="125" Column="61" TopLine="113"/>
|
||||||
</Position24>
|
</Position24>
|
||||||
<Position25>
|
<Position25>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="116" Column="44" TopLine="104"/>
|
<Caret Line="103" Column="38" TopLine="91"/>
|
||||||
</Position25>
|
</Position25>
|
||||||
<Position26>
|
<Position26>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="192" Column="35" TopLine="180"/>
|
<Caret Line="126" Column="32" TopLine="113"/>
|
||||||
</Position26>
|
</Position26>
|
||||||
<Position27>
|
<Position27>
|
||||||
<Filename Value="controller.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="74" Column="15" TopLine="59"/>
|
<Caret Line="125" Column="1" TopLine="108"/>
|
||||||
</Position27>
|
</Position27>
|
||||||
<Position28>
|
<Position28>
|
||||||
<Filename Value="../../../objc/objc.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="27" Column="12" TopLine="19"/>
|
<Caret Line="139" Column="1" TopLine="122"/>
|
||||||
</Position28>
|
</Position28>
|
||||||
<Position29>
|
<Position29>
|
||||||
<Filename Value="mytoolbar.pas"/>
|
<Filename Value="controller.pas"/>
|
||||||
<Caret Line="149" Column="9" TopLine="134"/>
|
<Caret Line="144" Column="44" TopLine="132"/>
|
||||||
</Position29>
|
</Position29>
|
||||||
<Position30>
|
<Position30>
|
||||||
<Filename Value="view.pas"/>
|
<Filename Value="view.pas"/>
|
||||||
<Caret Line="218" Column="77" TopLine="200"/>
|
<Caret Line="158" Column="29" TopLine="138"/>
|
||||||
</Position30>
|
</Position30>
|
||||||
</JumpHistory>
|
</JumpHistory>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
|
@ -97,6 +97,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{@@
|
{@@
|
||||||
|
Attaches event handlers for the menu
|
||||||
}
|
}
|
||||||
procedure TMyView.AttachEventHandlers();
|
procedure TMyView.AttachEventHandlers();
|
||||||
begin
|
begin
|
||||||
@ -106,11 +107,15 @@ begin
|
|||||||
SaveItem.setTarget(myController.Handle);
|
SaveItem.setTarget(myController.Handle);
|
||||||
SaveItem.setAction(sel_registerName(PChar('doSaveFile:')));
|
SaveItem.setAction(sel_registerName(PChar('doSaveFile:')));
|
||||||
|
|
||||||
|
SaveAsItem.setTarget(myController.Handle);
|
||||||
|
SaveAsItem.setAction(sel_registerName(PChar('doSaveAsFile:')));
|
||||||
|
|
||||||
ExitItem.setTarget(myController.Handle);
|
ExitItem.setTarget(myController.Handle);
|
||||||
ExitItem.setAction(sel_registerName(PChar('doClose:')));
|
ExitItem.setAction(sel_registerName(PChar('doClose:')));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@
|
{@@
|
||||||
|
Creates the Apple submenu
|
||||||
}
|
}
|
||||||
function TMyView.CreateAppleMenu(): NSMenu;
|
function TMyView.CreateAppleMenu(): NSMenu;
|
||||||
var
|
var
|
||||||
@ -130,6 +135,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{@@
|
{@@
|
||||||
|
Creates the File submenu
|
||||||
}
|
}
|
||||||
function TMyView.CreateFileMenu(): NSMenu;
|
function TMyView.CreateFileMenu(): NSMenu;
|
||||||
var
|
var
|
||||||
@ -145,13 +151,21 @@ begin
|
|||||||
|
|
||||||
OpenItem := CreateMenuItem('Open');
|
OpenItem := CreateMenuItem('Open');
|
||||||
Result.addItem(OpenItem.Handle);
|
Result.addItem(OpenItem.Handle);
|
||||||
|
|
||||||
SaveItem := CreateMenuItem('Save');
|
SaveItem := CreateMenuItem('Save');
|
||||||
Result.addItem(SaveItem.Handle);
|
Result.addItem(SaveItem.Handle);
|
||||||
|
|
||||||
|
SaveAsItem := CreateMenuItem('Save As');
|
||||||
|
Result.addItem(SaveAsItem.Handle);
|
||||||
|
|
||||||
|
Result.addItem(NSMenuItem.separatorItem.Handle);
|
||||||
|
|
||||||
ExitItem := CreateMenuItem('Exit');
|
ExitItem := CreateMenuItem('Exit');
|
||||||
Result.addItem(ExitItem.Handle);
|
Result.addItem(ExitItem.Handle);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@
|
{@@
|
||||||
|
Adds a submenu to the main menu
|
||||||
}
|
}
|
||||||
procedure TMyView.AddToMenubar(menu: NSMenu);
|
procedure TMyView.AddToMenubar(menu: NSMenu);
|
||||||
var
|
var
|
||||||
@ -164,6 +178,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{@@
|
{@@
|
||||||
|
Creates the toolbar object. Setting the items is done in the controller.
|
||||||
}
|
}
|
||||||
function TMyView.CreateToolbar(AOwnerView: NSView; AX, AY, AWidth,
|
function TMyView.CreateToolbar(AOwnerView: NSView; AX, AY, AWidth,
|
||||||
AHeight: Double): NSToolbar;
|
AHeight: Double): NSToolbar;
|
||||||
@ -174,6 +189,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{@@
|
{@@
|
||||||
|
Creates the main menu
|
||||||
}
|
}
|
||||||
procedure TMyView.CreateMainMenu();
|
procedure TMyView.CreateMainMenu();
|
||||||
begin
|
begin
|
||||||
@ -190,6 +206,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{@@
|
{@@
|
||||||
|
Creates a new menu item from a title
|
||||||
}
|
}
|
||||||
function TMyView.CreateMenuItem(ATitle: shortstring): NSMenuItem;
|
function TMyView.CreateMenuItem(ATitle: shortstring): NSMenuItem;
|
||||||
var
|
var
|
||||||
|
Reference in New Issue
Block a user