Home Installation Release notes Language Reference Support Downloads Tutorials FutureBasic 5 Links

Working with nibs - Button

1. Launch Xcode
 

2. Choose File > New > File… (⌘N)


 

3. At the top of the choose template sheet...
a) click "macOS"
b) under 'User Interface', select "Window"
c) click "Next" button


 

4. Click "Create" button to save the xib file as "Window"


 

5. Choose View > Libraries > Show Library (⇧⌘L)


 

6. Drag a Push Button from the Objects panel to the window


 

7. With the button still selected, click on the Attributes Inspector Icon at the top right, scroll down to View and enter '1' in the 'Tag' field


 

8. Save the changes
 

9. In FutureBasic, create a new file and paste the following code

include "NSLog.incl"

void local fn BuildWindow
// params: windowTag, nibName
nibwindow 1, @"Window"
end fn

void local fn DoDialog( ev as long, tag as long, wnd as long )
select ( ev )
case _btnClick
NSLog(@"Button %ld clicked in window %ld",tag,wnd)
end select
end fn

fn BuildWindow

on dialog fn DoDialog

HandleEvents
 

10. Save the FB file to the same folder as the nib and run it