cpr.core.AppInstance

App instance class. Have information about your app

Index

Events
Event Description
before-context-value-change Use a bind context in a control that has a bind context An event that occurs before the value changes.
blur An event that occurs after the control loses focus.
click An event that occurs when the user clicks the control.
context-value-change Use a bind context in a control that has a bind context An event that occurs after the value changes.
contextmenu When the right mouse button is clicked or the context menu key is pressed, Event called.
dblclick An event that occurs when the user double-clicks the control.
dragenter When the mouse pointer enters the elements included in the control while dragging Events that occur.
dragleave During the drag, the mouse pointer may have exited the elements contained in the control.
dragover While dragging the source control with the mouse, the mouse pointer An event that occurs when moving within a region.
drop Drag the source control to the target control while dragging the source control with the mouse.
focus The event that occurs after the control gains focus.
host-change This event occurs when the app is included in or leaves the parent app.
init An event that occurs when the app is initially configured.
keydown Event raised when the user presses a key.
keyup Event that occurs when the user releases the key.
load An event that occurs immediately after the initial render of the app.
mousedown When the user presses the mouse button with the pointer over the control Occurs when an event occurs.
mouseenter An event that occurs when the mouse pointer enters the control.
mouseleave If the user moves the mouse pointer beyond the control and its children Events that occur when moving.
mousemove This event is raised when the user moves the pointer over the control.
mouseup The user releases the mouse button while over the control.
property-change Event that fires when an app's properties change.
screen-change Event called when the screen size changes.
touchcancel What happens when one or more touch points are interrupted in a particular implementation event.
touchend What happens when one or more touch points are removed from the touch surface event.
touchmove What happens when one or more touch points move along the touch surface event.
touchstart What happens when one or more touch points are placed on a touch surface event.
unload An event that occurs after the app has been unloaded.
Properties
Name Type Description
allSupportedMediaNames String[] Returns the names of all supported screens.
allSupportedMedias String[] Get each media query for all supported screens.
allSupportedScreens Screen[] Get all screen objects supported by this app instance.
app App App object
dialogManager DialogManager Dialog manager
disposed Boolean Whether the app was destroyed.
focuscyclic Boolean Whether to return from the last focus to the beginning.
id String Your app's id
rendered Boolean Returns whether the app has ever been displayed on the screen.
state AppInstanceState Get the state of the app instance.
targetMedia String Gets a media query for the currently active screen.
targetMediaName String Gets the name of the currently active screen.
targetScreen Screen Gets the currently active Screen object.
uuid String Your app's unique ID
Methods
Name Return Type Description
addBindableAppProperty Add a property of the bindable app.
addEventListener Add a Listener for each EventType to the control.
addEventListenerOnce (e: cpr.events.CEvent)=>Void Add a Listener to the control that will run only once per EventType.
applyAppMethod Object Call the app method.
bindAppProperty IBindFactory Bind the properties of the app.
bringFloatingControlToTop Among the floatControl and Dialog floating in the App, the specific control is displayed as the top level.
callAppMethod Object Call the app method.
close Boolean Close the app.
createWorkflow Workflow Creates and returns a Workflow object that can access the controls in AppInstance.
declareAppProperty Declare app properties.
declareBindableAppProperty Declare bindable app properties.
dispatchEvent Boolean Forwards specific events.
dispose Removes the objects contained in the control.
findControlsAt UIControl[] Use the coordinates in the browser viewport to obtain the controls that exist below those coordinates.
floatControl Floats a control at a specific location in the app.
focus Gives focus to a specific UIControl in the App.
focusNext Moves focus to the next control.
focusPrevious Moves the focus to the previous control.
getActualRect Rectangle The app returns the actual drawn size.
getAllAppProperties {[key:string]: Object} Get all app properties.
getAllDataControls Control[] Get all data controls (datasets, views, maps, submissions) registered in the app instance.
getAppProperty Object Returns the properties of the app.
getAppPropertyAsBoolean Boolean Returns the app properties as a boolean type.
getAppPropertyAsNumber Number Returns the app properties as a number type.
getAppPropertyAsString String Returns the app properties as a string.
getAppPropertyBindInfo BindInfo Returns the bind attribute information of the app.
getBindContext BindContext Returns the bind context.
getContainer Container Returns the container of the app.
getFirstFocusTraversableControl UIControl You get a UI control with the first focus traversal sequence via the tab key.
getFirstFocusableUIControl UIControl You get a UI control with the first focus traversal sequence via the tab key.
getFloatedControls UIControl[] Get the floating controls.
getFloatingControls UIControl[] Get the floating controls.
getHost EmbeddedApp Returns the embedded app object.
getHostAppInstance AppInstance Returns the appInstance of the embedded app.
getHostProperty Object Returns the properties of the embedded app control.
getLastFocusTraversableControl UIControl Gets the UI control with the last focus traversal sequence via the tab key.
getLastFocusableUIControl UIControl Gets the UI control with the last focus traversal sequence via the tab key.
getModule Object Returns Module.
getPreferredSize Dimension When the app runs, it gets the minimum size information it needs.
getRootAppInstance AppInstance Returns the top-level app instance.
hasAppMethod Boolean Returns whether the app has a method.
isBindableAppProperty Boolean Returns whether there is a property of bindable app.
isEmbeddedAppInstance Boolean Returns whether the app is an embedded app.
isRootAppInstance Boolean Returns whether or not it is the root App.
isUDCInstance Boolean Returns whether this app instance is a UDC app instance.
lookup Identifiable Find the object by its ID.
lookupByUUID Identifiable Find the object by UUID.
openDialog Promise<Object> Open the dialog in the app.
register Registers identifiable objects.
removeAllEventListeners Removes all event listeners for the control.
removeAllFloatingControls Remove floatControl and Dialog floating in the App.
removeEventListener Remove Listener by EventType from control.
removeFloatingControl Removes certain controls among floatControl and Dialog floating in the App.
requireModule Module Loads and returns the common module created in the project.
run AppInstance Run the app.
setAppProperties Specify multiple app properties at once.
setAppProperty Set your app's properties.
setHostProperty Set the properties of the embedded app control to which it belongs.
setPreferredSize Specifies the minimum size required for the app instance to function.
setTargetMedia Specifies the currently active media.
supportMedia Add a media query that describes the supported screen specifications.
unbindAppProperty Unbind the properties of the app.
unregister Removes the registered object.
unsetAllAppProperties Returns all app properties with default values ​​to their default state.
unsetAppProperty Returns the values ​​of certain app properties to their default values.

Events

before-context-value-change
CValueChangeEvent Use a bind context in a control that has a bind context An event that occurs before the value changes.
blur
CFocusEvent An event that occurs after the control loses focus.
click
CMouseEvent An event that occurs when the user clicks the control.
context-value-change
CValueChangeEvent Use a bind context in a control that has a bind context An event that occurs after the value changes.
contextmenu
CMouseEvent When the right mouse button is clicked or the context menu key is pressed, Event called.
dblclick
CMouseEvent An event that occurs when the user double-clicks the control.
dragenter
CMouseEvent When the mouse pointer enters the elements included in the control while dragging Events that occur.
dragleave
CMouseEvent During the drag, the mouse pointer may have exited the elements contained in the control. The event that occurs when.
dragover
CMouseEvent While dragging the source control with the mouse, the mouse pointer An event that occurs when moving within a region.
drop
CMouseEvent Drag the source control to the target control while dragging the source control with the mouse. Event that fires when dropping.
focus
CFocusEvent The event that occurs after the control gains focus.
host-change
CEvent This event occurs when the app is included in or leaves the parent app.
init
CEvent An event that occurs when the app is initially configured.
keydown
CKeyboardEvent Event raised when the user presses a key. Keycode related constants can be referenced at KeyCode.
keyup
CKeyboardEvent Event that occurs when the user releases the key. Keycode related constants can be referenced at KeyCode.
load
CEvent An event that occurs immediately after the initial render of the app.
mousedown
CMouseEvent When the user presses the mouse button with the pointer over the control Occurs when an event occurs.
mouseenter
CMouseEvent An event that occurs when the mouse pointer enters the control.
mouseleave
CMouseEvent If the user moves the mouse pointer beyond the control and its children Events that occur when moving.
mousemove
CMouseEvent This event is raised when the user moves the pointer over the control.
mouseup
CMouseEvent The user releases the mouse button while over the control. When an event occurs.
property-change
CPropertyChangeEvent Event that fires when an app's properties change.
screen-change
CScreenChangeEvent Event called when the screen size changes.
touchcancel
CTouchEvent What happens when one or more touch points are interrupted in a particular implementation event.
touchend
CTouchEvent What happens when one or more touch points are removed from the touch surface event.
touchmove
CTouchEvent What happens when one or more touch points move along the touch surface event.
touchstart
CTouchEvent What happens when one or more touch points are placed on a touch surface event.
unload
CEvent An event that occurs after the app has been unloaded.

Properties

allSupportedMediaNames
type String[]
readonly
Returns the names of all supported screens.
allSupportedMedias
type String[]
readonly
Get each media query for all supported screens.
allSupportedScreens
type Screen[]
readonly
Get all screen objects supported by this app instance. The return value is a read-only copy object.
app
type App
readonly
App object
dialogManager
type DialogManager
readonly
Dialog manager
disposed
type Boolean
readonly
Whether the app was destroyed.
focuscyclic
type Boolean
get
Whether to return from the last focus to the beginning.
set
Sets whether to return from the last focus to the beginning.
id
type String
readonly
Your app's id
rendered
type Boolean
readonly
Returns whether the app has ever been displayed on the screen. If it has been displayed on the screen even once for the first time, true, Returns false if it has never been displayed.
state
type AppInstanceState
readonly
Get the state of the app instance.
targetMedia
type String
readonly
Gets a media query for the currently active screen.
targetMediaName
type String
readonly
Gets the name of the currently active screen.
targetScreen
type Screen
readonly
Gets the currently active Screen object. The return value is a read-only copy object.
uuid
type String
readonly
Your app's unique ID

Methods

addBindableAppProperty(name, initialValue)
deprecatedPlease use declareBindableAppProperty.
Add a property of the bindable app.
Parameters
name type description
name String Attribute name
initialValue Object Initial value
addEventListener(type, listener)
Add a Listener for each EventType to the control.
Add a listener that handles when a specific event occurs in the control.
var button = new cpr.controls.Button("btn01");
button.addEventListener("click", function(e) {
	//event code...
});
Parameters
name type description
type String Event type.
listener (e: cpr.events.CEvent)=>Void Event listeners.
addEventListenerOnce(type, listener)
Add a Listener to the control that will run only once per EventType.
Add a listener that handles when a specific event occurs in the control. The added listener is automatically deleted after it is run once. Since the object of the added listener changes, when deleting the listener The object returned after calling addEventListenerOnce can be deleted.
var button = new cpr.controls.Button("btn01");
button.addEventListenerOnce("click", function(e) {
	//event code...
});
Parameters
name type description
type String Event type.
listener (e: cpr.events.CEvent)=>Void Event listeners.
return (e: cpr.events.CEvent)=>Void The modified Listener object.
applyAppMethod(name, args)
Call the app method. Unlike callAppMethod() passing arguments in a spread form, it passes arguments as a single array.
Parameters
name type description
name String The name of the app method to be called.
args Array Call argument.
return Object
bindAppProperty(name)
Bind the properties of the app.
Parameters
name type description
name String Attribute name.
return IBindFactory IBindFactory
bringFloatingControlToTop(control)
Among the floatControl and Dialog floating in the App, the specific control is displayed as the top level.
Parameters
name type description
control UIControl
callAppMethod(name, args)
Call the app method.
Parameters
name type description
name String The name of the app method to be called.
args Array Call argument.
return Object
close(returnValue)
Close the app.
Parameters
name type description
returnValueoptional Object If your app is working within a dialog, you can pass the return value while closing the app.
return Boolean
createWorkflow(debug)
Creates and returns a Workflow object that can access the controls in AppInstance.
Parameters
name type description
debugoptional Boolean defaultfalse
return Workflow cpr.foundation.Workflow
declareAppProperty(propName, defaultValue)
Declare app properties.
Parameters
name type description
propName String Attribute name.
defaultValue Object Default value.
declareBindableAppProperty(propName, defaultValue)
Declare bindable app properties.
Parameters
name type description
propName String Attribute name.
defaultValue Object Default value.
dispatchEvent(e)
Forwards specific events.
Parameters
name type description
e CEvent event
return Boolean
dispose()
Removes the objects contained in the control.
findControlsAt(clientLocation)
Use the coordinates in the browser viewport to obtain the controls that exist below those coordinates. They are returned in order, starting from the frontmost one on the screen.
Parameters
name type description
clientLocation Point Viewport coordinates to retrieve.
return UIControl[]
findControlsAt(x, y)
Use the coordinates in the browser viewport to obtain the controls that exist below those coordinates. They are returned in order, starting from the frontmost one on the screen.
Parameters
name type description
x Number Viewport X-coordinate (clientX)
y Number Viewport Y coordinate (clientY)
return UIControl[]
floatControl(control, styles)
Floats a control at a specific location in the app. Regardless of the layout, separate from the UIControl added to the app's container This method is used when you want to randomly position a control at a specific location within the app. This can be used, for example, to output a context menu.
Parameters
name type description
control UIControl UIControl to populate the App area.
stylesoptional {[key:string]: String} default{} A style or cpr.geometry.Rectangle object that describes the position of the control to be displayed.
focus(controlOrId, forward)
Gives focus to a specific UIControl in the App.
Parameters
name type description
controlOrId UIControl The ID of the UIControl to get focus or a UIControl object
forwardoptional Boolean defaulttrue
focusNext(control)
Moves focus to the next control.
Parameters
name type description
control UIControl The control that currently owns focus.
focusPrevious(control)
Moves the focus to the previous control.
Parameters
name type description
control UIControl The control that currently owns focus.
getActualRect(options)
The app returns the actual drawn size.
If the app is not drawn on the screen, an object with all values ​​of 0 is returned.
Parameters
name type description
optionsoptional { scaled?: Boolean }
return Rectangle
getAllAppProperties()
Get all app properties.
return {[key:string]: Object}
getAllDataControls()
Get all data controls (datasets, views, maps, submissions) registered in the app instance.
return Control[]
getAppProperty(propertyName)
Returns the properties of the app.
Parameters
name type description
propertyName String The name of the attribute.
return Object Property of the app.
getAppPropertyAsBoolean(propertyName)
deprecatedThis function was provided for type inference in the script editor. Please use getAppProperty.
Returns the app properties as a boolean type.
Parameters
name type description
propertyName String Attribute Name
return Boolean
getAppPropertyAsNumber(propertyName)
deprecatedThis function was provided for type inference in the script editor. Please use getAppProperty.
Returns the app properties as a number type.
Parameters
name type description
propertyName String Attribute Name
return Number
getAppPropertyAsString(propertyName)
deprecatedThis function was provided for type inference in the script editor. Please use getAppProperty.
Returns the app properties as a string.
Parameters
name type description
propertyName String Attribute Name
return String
getAppPropertyBindInfo(name)
Returns the bind attribute information of the app.
Parameters
name type description
name String The name of the attribute being bound.
return BindInfo BindInfo Properties
getBindContext()
Returns the bind context.
return BindContext bind context
getContainer()
Returns the container of the app.
return Container container
getFirstFocusTraversableControl()
You get a UI control with the first focus traversal sequence via the tab key.
return UIControl
getFirstFocusableUIControl()
deprecatedThe name was changed due to ambiguous terminology. Please use getFirstFocusTraversableControl instead.
You get a UI control with the first focus traversal sequence via the tab key.
return UIControl
getFloatedControls()
deprecatedPlease use getFloatingControls.
Get the floating controls.
return UIControl[]
getFloatingControls()
Get the floating controls.
return UIControl[]
getHost()
Returns the embedded app object.
return EmbeddedApp
getHostAppInstance()
Returns the appInstance of the embedded app.
return AppInstance
getHostProperty(name)
Returns the properties of the embedded app control. That property must be a bindable property.
Parameters
name type description
name String The name of the attribute.
return Object
getLastFocusTraversableControl()
Gets the UI control with the last focus traversal sequence via the tab key.
return UIControl
getLastFocusableUIControl()
deprecatedThe name was changed due to ambiguous terminology. Please use getLastFocusTraversableControl instead.
Gets the UI control with the last focus traversal sequence via the tab key.
return UIControl
getModule()
Returns Module.
return Object Module
getPreferredSize()
When the app runs, it gets the minimum size information it needs.
return Dimension
getRootAppInstance()
Returns the top-level app instance.
return AppInstance root app.
hasAppMethod(name)
Returns whether the app has a method.
Parameters
name type description
name String method name.
return Boolean Include method.
isBindableAppProperty(name)
Returns whether there is a property of bindable app.
Parameters
name type description
name String Attribute name.
return Boolean
isEmbeddedAppInstance()
Returns whether the app is an embedded app.
return Boolean Whether you have an embedded app.
isRootAppInstance()
Returns whether or not it is the root App.
return Boolean Whether it is the root app.
isUDCInstance()
Returns whether this app instance is a UDC app instance.
return Boolean
lookup(id)
Find the object by its ID.
Parameters
name type description
id String The ID of the object to find.
return Identifiable
lookupByUUID(uuid)
Find the object by UUID.
Parameters
name type description
uuid String The UUID of the object to find.
return Identifiable
openDialog(appId, prop, handler)
Open the dialog in the app. To change the app of an existing dialog, use the dialogName property of DialogManager.openDialog.
app.openDialog("dlgs/people", {width:400, height:300});
Parameters
name type description
appId #app The ID of the app to open
prop AppOpenDialogOption The Property to define the properties of the Dialog.
handleroptional (dlg: cpr.controls.Dialog)=>Void If you need to handle the Dialog object more specifically, you can add handlers to handle the Dialog (you can add event handlers, change styles, etc.)
return Promise<Object> Promise chain to be connected when the dialog is closed. It is called only when there is a dialog return value.
openDialog(app, prop, handler)
Open the dialog in the app. To change the app of an existing dialog, use the dialogName property of DialogManager.openDialog.
app.openDialog(appToShow, {width:400, height:300});
Parameters
name type description
app App App to open
prop AppOpenDialogOption The Property to define the properties of the Dialog.
handleroptional (dlg: cpr.controls.Dialog)=>Void If you need to handle the Dialog object more specifically, you can add handlers to handle the Dialog (you can add event handlers, change styles, etc.)
return Promise<Object> Promise chain to be connected when the dialog is closed. It is called only when there is a dialog return value.
register(object)
Registers identifiable objects.
Parameters
name type description
object Identifiable The object to register.
removeAllEventListeners()
Removes all event listeners for the control.
removeAllFloatingControls(shouldDispose)
Remove floatControl and Dialog floating in the App.
Parameters
name type description
shouldDisposeoptional Boolean defaultfalse Whether to dispose at the same time as removal.
removeEventListener(type, listener)
Remove Listener by EventType from control.
control.removeEventListener('click', listener);
Parameters
name type description
type String Event type.
listener (e: cpr.events.CEvent)=>Void Event listeners.
removeFloatingControl(control, shouldDispose)
Removes certain controls among floatControl and Dialog floating in the App.
Parameters
name type description
control UIControl Instance of UIControl to remove.
shouldDisposeoptional Boolean defaultfalse Whether to dispose at the same time as removal.
requireModule(qualifiedName)
Loads and returns the common module created in the project.
If the file name of the common module you want to load is com.module.js, the qualifiedName is lib.com.
var mod_com = app.requireModule("lib.com");
Parameters
name type description
qualifiedName String The ID of the Module to load.
return Module
run(host, callback)
Run the app.
Parameters
name type description
hostoptional EmbeddedApp App
callbackoptional (app: cpr.core.AppInstance)=>Void The callback function to execute.
return AppInstance
setAppProperties(properties, fireEvent)
Specify multiple app properties at once.
Parameters
name type description
properties {[key:string]: Object} The attribute JSON object to specify.
fireEventoptional Boolean defaulttrue Whether to propagate property-change events.
setAppProperty(propertyName, value, fireEvent)
Set your app's properties.
Parameters
name type description
propertyName String The name of the attribute.
value Object The value of the attribute
fireEventoptional Boolean defaulttrue Whether to propagate property-change events.
setHostProperty(name, value)
Set the properties of the embedded app control to which it belongs. That property must be a bindable property.
Parameters
name type description
name String Attribute Name
value Object The value of the attribute
setPreferredSize(width, height)
Specifies the minimum size required for the app instance to function.
Parameters
name type description
width Number Minimum width. Negative numbers indicate no constraint.
height Number Minimum height. Negative numbers indicate no constraint.
setPreferredSize(size)
Specifies the minimum size required for the app instance to function.
Parameters
name type description
size Dimension Minimum size
setTargetMedia(targetMedia)
deprecatedIt was discovered that this API was inadvertently leaked as it was supposed to be called from within the system.
Specifies the currently active media.
Parameters
name type description
targetMedia String The currently active media or screen name
supportMedia(mediaQuery, mediaName)
Add a media query that describes the supported screen specifications. This method can only be called while the app is initializing. Otherwise it is ignored.
Parameters
name type description
mediaQuery String Media query to add.
mediaNameoptional String defaultnull
unbindAppProperty(name)
Unbind the properties of the app.
Parameters
name type description
name String Attribute name.
unregister(object)
Removes the registered object.
Parameters
name type description
object Identifiable The object to remove.
unsetAllAppProperties(fireEvent)
Returns all app properties with default values ​​to their default state. The values ​​of all app properties declared with declareAppProperty() and declareBindableAppProperty() are reset to their initial values.
Parameters
name type description
fireEventoptional Boolean defaulttrue Whether to propagate property-change events.
unsetAppProperty(propertyName, fireEvent)
Returns the values ​​of certain app properties to their default values.
Parameters
name type description
propertyName String App property name to return to default.
fireEventoptional Boolean defaulttrue Whether to propagate property-change events.