Thanks! I'm flattered! =)
1. There's not way to setup event handling visually with IB. Just beacuse IB knows nothing about the programming language it's going to be used by.
2. I think it's quite possible to use IB created pages with Lazarus applications. IB routines simply creates MacOS windows and controls and lays them out as designed. The required thing is to assign control handles to the widgetset objects, so IB created controls can be used easily.
Here's the sample =)
Start new lazarus application. Place a single button on the form. And build and Run, Lazaurs should create an application bundle.
Close the application, and open it's bundle. You need to copy main.nib file from the bundle of the previous tutorial, to the Lazarus application bundle. Don't forget that bundle must be located in the Bundle/Contents/Resources folder.
Now return to the Lazarus and open Form unit. Assign OnClick event handler for the button.
Paste following code to it.
procedure TForm1.Button1Click(Sender: TObject);
var
err : Integer;
nibRef : IBNibRef;
winref : WindowRef;
NibForm : TForm;
begin
err := CreateNibReference(CFSTR('main'), nibRef);
if err <> noErr then Exit;
try
err := CreateWindowFromNib(nibRef, CFSTR('Window'), winref);
if err <> noErr then Exit;
// creating a widgetset object (TForm)
NibForm := TForm.Create(Application);
//HACK: this code is not cross-platform, and will work for Carbon only!
//binding widgetset object and MacOS system object winref: WindowRef
TCarbonWindow(NibForm.Handle).Widget := winref;
// Now Nib created window can be manipulated by the LCL object
NibForm.Show;
NibForm.Caption := 'Hello LCL!';
finally
DisposeNibReference(nibRef);
end;
end;
add: FPCMacOSALL and CarbonPrivate untis to the uses
That's it! Pressing the button should open IB created window!
threre're two problems with this method
1) it's not cross-platfrom
2) it requires you STRONG knowledge of LCL and carbon widgetst internals!
The solution is the similiar to the one in Windows, then you want to create new Win controls by calling winAPI functions and use them with LCL (delphi VCL) code.