Application

From REALbasicWiki

Jump to: navigation, search

Contents

[edit] Description

An Application is the main class of a REALbasic application. In your project, you implement a subclass of Application, and a single instance of it is created at runtime.

[edit] Superclass

Application inherits from Object.

[edit] Interfaces

None.

[edit] Constants

[edit] Development = 0

[edit] Alpha = 1

[edit] Beta = 2

[edit] Final = 3

[edit] Methods

[edit] Sub AddTrayItem(item as TrayItem)

[edit] Sub DoEvents(milliseconds as Integer = -1)

Invoke one iteration of the main event loop, optionally allowing the app to sleep for the specified number of milliseconds.

History and appropriate usage of DoEvents

[edit] Sub NewDocument()

Calls the NewDocument event handler.

[edit] Sub OpenDocument(item as FolderItem)

Calls the OpenDocument event handler.

[edit] Sub RemoveTrayItem(item as TrayItem)

[edit] Sub SleepCurrentThread(milliseconds as Integer)

Tells the thread in which it is called to sleep for the number of milliseconds passed. This includes the main application thread.

[edit] Sub YieldToNextThread()

[edit] Events

See Events order on application startup for a description of Open, OpenDocument and NewDocument.

[edit] Sub Activate()

[edit] Function CancelClose() as Boolean

[edit] Sub Close()

[edit] Sub Deactivate()

[edit] Sub EnableMenuItems()

[edit] Function HandleAppleEvent(theEvent As AppleEvent, eventClass As String, eventID As String) As Boolean

[edit] Sub NewDocument()

[edit] Sub Open()

[edit] Sub OpenDocument(item as FolderItem)

[edit] Function UnhandledException(exc as RuntimeException) as Boolean

This event handler is called when an exception percolates to the top of the calling chain. Return true to catch the exception, i.e. let the application continue to run. Return false to let the exception continue; this will result in the application quitting after displaying a generic error message. Note that UnhandledException is not called for exceptions raised in the Open and Close event handlers.

[edit] Properties

AutoQuit as Boolean

[edit] Compile-Time Settings

[edit] Bundle Identifier

For Mac OS X builds, you should enter a bundle identifier. By convention, this is a string in so-called reverse domain name form; i.e. com.declareSub.foo. See [[1]] for more information.

[edit] Discussion

A REALbasic application has a single instance of Application, returned by the global App function.

Catch-all exception handling in UnhandledException is usually poor design.


[edit] Sample Code

Personal tools
related