AppleWindow - UBogun/Xojo-iosLib GitHub Wiki

Inherits from AppleView
Memory leak check: not yet done.
Status: completed.

This is an implementation of UIWindow, a UIView subclass that is the basic view subclass behind all your views. Unless your app can display content on an external device screen, an app has only one window.
UIWindow is the place to catch keyboard display events. The related events carry a custom iOSLibKeyboardEventDictionary (see Definition below) subclass of AppleDictionary to read the properties easily.

The events of UIView are not available here, you will usually use this class derived from the UIWindow that was already created by the IDE for you.

General information

UIVIew Basics

Xojo integration

Although AppleWindow is an AppleView subclass, you will usually not address its view parameters for screen handling directly. Therefore there is no Xojo control.
To make use of AppleWindow's features, create an object somewhere in your app
myWindow = self.view.window and tweak the event handlers to your own methods or create a subclass that handles the events. In the first case, don’t forget to remove the handlers on app quit.

Constructor

Constructor (Frame As FoundationFramework.NSRect): Pass the bounds of an additional Screen to create a window for it.

Properties

KeyWindow As Boolean: Whether the window is the key window for the application. _The setter of this property works only for a true value by calling the hidden setMakeKeyWindow method. IF you want to resign key state, make another Window the key window.

RootViewController As AppleViewController: The root view controller for the window.

Screen As AppleScreen: The screen on which the window is currently displayed.

WindowLevel As Double: The window level. Refer to the three UIWindowLevel class constants for typical values.

UIWindowLevel Constants

Name value
UIWindowLevelNormal 0.0
UIWindowLevelStatusBar 1000.0
UIWindowLevelAlert 2000.0

Methods

ConvertPointFromWindow (Point As FoundationFramework.NSPoint, window as AppleWindow) As FoundationFrameWork.NSPoint: Converts a point from the coordinate system of a given window to that of the current window.

ConvertPointToWindow (Point As FoundationFramework.NSPoint, window as AppleWindow) As FoundationFrameWork.NSPoint: Converts a point from the window’s coordinate system to that of another window.

ConvertRectFromWindow (Rect As FoundationFramework.NSRect, window as AppleWindow) As FoundationFrameWork.NSRect: Converts a rectangle from the coordinate system of another window to that of the current window.

ConvertRectToWindow (Rect As FoundationFramework.NSRect, window as AppleWindow) As FoundationFrameWork.NSRect: Converts a rectangle from the window’s coordinate system to that of another window.

MakeKeyAndVisible(): Makes the window the key window and visible.

SendEvent (AnEvent As AppleNSEvent): Dispatches events sent to the window by the UIApplication object to its views. You will usually not need to call this method, event handling is done automatically if you don't intercept it.

Events

BecameKeyWindow(): The window has attained key window state.

DidChangeKeyboardFrame (UserDict as iOSLibKeyboardEventDictionary): The Frame of the displayed keyboard has changed which could be caused by a device rotation.

DidHideKeyboard (UserDict as iOSLibKeyboardEventDictionary): The keyboard was hidden.

DidShowKeyboard (UserDict as iOSLibKeyboardEventDictionary): The keyboard is visible.

Hidden(): The window became hidden.

ResignedKeyWindow(): The window has lost key window state.

Shown(): The window is displayed.

WillChangeKeyboardFrame (UserDict as iOSLibKeyboardEventDictionary): The keyboard frame will change, which could be caused by a device rotation.

WillHideKeyBoard:(UserDict as iOSLibKeyboardEventDictionary): The keyboard will be hidden.

WillShowKeyBoard:(UserDict as iOSLibKeyboardEventDictionary): The keyboard will be shown.

Helper class

iOSLibKeyboardEventDictionary

is a subclass of AppleDictionary for easy access to the parameters that the keyboard events define:

Properties (all read-only):

AnimationCurve As AppleView.UIViewAnimationCurve: The animation curve with that the keyboard will be animated during display & hide.

AnimationDuration As Double: The keyboard hide/display animation time.

BeginFrame As FoundationFramework.NSRect: The start frame of the keyboard animation in screen coordinates. Should be converted to window or view coordinates.

EndFrame As FoundationFramework.NSRect: The end frame of the keyboard animation in screen coordinates. Should be converted to window or view coordinates.

LocalKeyboard As Boolean: Whether the Keyboard belongs to the current app.