
|
<<
Index
>>
|
FutureBasic
|
|
Interface elements
|
|
Manual
|
|
Windows
Windows are created with the window statement and are positioned relative to the bottom-left of the screen. A window is identified by its tag value. Many of the window statement parameters are optional and if omitted will default to appropriate values.
Widgets
- Widget refers to the various User Interface (UI) elements found within a window, such as push buttons, radio buttons, textfields, tableviews and other views etc.
- Widgets can be created in one of two ways:
- programmatically in FB code - the focus of this discussion
- within Xcode ( see "Working with nibs" below for more on nibs ).
- Each widget has its own FB keyword which creates, manipulates and specifies various aspects/properties of the widget such as location within the window, size etc.
- A widget's FB keyword can have several parameters but has at least one parmeter, usually named rect, which accepts four coordinates ( x, y, width, height )
- The rect specifies the widget's location within the window and usually this means within the window's content view. But widgets can be nested within a view, so within a parent view is more accurate.
- A widget's position, as specified by the x & y coordinates within the rect, refers to the bottom-left of the window's content view or parent view if the widget is nested in another view.
- N.B. while a widget's position is specified relative to bottom-left, FB drawing and printing to a window, such as the print command, are relative to top-left
- A widget statement can have both required and optional parameters and a widget's keyword help page defines them. Omitted optional parameters default to appropriate values.
- A widget keyword associates a tag value, which is a unique integer for that type of widget within a view, with the widget. The tag value (or a user FB constant assigned that value) can be subsequently used to reference the widget.
Menus
Menus and menu items are created using the menu statement. Menus and items are identified by their index value (item indexes are zero-based). A menu with an index value in the range 1 - 100 is placed in the main menu. Menus with indexes of 101+ are built off-screen.
Autoreleased objects
ALL interface element functions (even those with names containing the words ‘init’, 'create' or ‘copy') return autoreleased objects so these objects must not be CFRelease(d).
Working with nibs
With nib files, you create and manipulate your user interfaces graphically, using Xcode, instead of programmatically.
Because you can see the results of your changes instantly, you can experiment with different layouts and configurations very quickly.
You can also change many aspects of your user interface later without rewriting any code.
Subclassing nib elements
To subclass a widget contained in a nib, change the widget's class name in the identity inspector.
For example, to subclass a nib textfield, set its class name to "TextFieldSC".
Note class names are case-sensitive and are made up of the widget name plus "SC" suffix.
Tutorials
Nib tutorials