class View
An abstract class that represents a view.
abstract
class View extends ManagedObject
Description
The view is one of the main architectural components of a Desk application. It provides a method to render its encapsulated content, either directly or using a collection of built-in UI components.
Views can be rendered on their own (using app.render(), app.showPage(), or app.showDialog()) or included as content within another view. In most cases, a top-level view is rendered from the Activity.ready() method.
The View class can’t be used on its own. Instead, define views using the following classes and methods:
- UIComponent classes, and the various ui factory functions (e.g.
ui.button(...)
) that create preset constructors for built-in UI components. - Specifically, UIContainer classes such as UICell, UIRow, and UIColumn, which represent containers that contain further UI components (and containers). These can be used to lay out your UI.
- Built-in ViewComposite classes, which control an encapsulated view — such as UIConditionalView and UIListView.
- The ViewComposite.withPreset() function, which creates a custom ViewComposite subclass.
Use the View class itself as a type, along with ViewClass, when referencing variables or parameters that should refer to any other view.
Constructor
- constructor()Creates a new managed object.
Type Members
- type View.ViewPreset staticType definition for the object that can be used to initialize a preset view.
Instance Members
- render(callback) abstractA method that should be implemented to render a View object.
- requestFocus() abstractA method that should be implemented to request input focus on the view output element.
- findViewContent(type) abstractA method that should be implemented to find matching components in the view hierarchy.
- applyViewPreset(preset)Applies the provided preset properties to this object.
Inherited Members
- emit(event)Emits an event, immediately calling all event handlers.
- emitChange(name?, data?)Emits a change event, an instance of ManagedChangeEvent.
- listen(handler)Adds a handler for all events emitted by this object.
- isUnlinked()Returns true if the object has been unlinked.
- unlink()Unlinks this managed object.
- beforeUnlink() protectedA method that’s called immediately before unlinking an object, can be overridden.
- attach(target, observer?) protectedAttaches the provided managed object to this object.
- autoAttach(propertyName, observer?) protectedObserves a property, so that any object assigned to it is attached immediately.
Related
- class UIComponent abstractBase class for built-in UI components.
- class ViewComposite abstractA class that encapsulates a dynamic view.