Moscrif.Window Class
This class encapsulates top level window (application).
Item Index
Methods
- this constructor
- add
- find
- init
- invalidate
- performLayout
- removeAll
- resumeLayout
- run
- suspendLayout
Properties
Methods
this
                      - [name]
Constructor - creates new instance of Window class.
Parameters:
- 
                            [name]String optionalWindow's name. 
Returns:
Example:
var app = new Moscrif.Window();
app.onStart = function()
{
    ...
}
app.onProcess = function(sender)
{
    return 1;
    // return 0 to quit application
}
app.init().run();
add
                      - view
- [order]
Function adds existing view object into this window.
Parameters:
- 
                            viewViewView to add. View/ScrollView/TextView are supported. 
- 
                            [order]Symbol optionalDefault is #back. Value is * #front * #back
Returns:
Example:
    var container = new Moscrif.View("container");
    ... width, height, onDraw ...
    app.add(container);
    var itemA = new Moscrif.View("itemA");
    ... width, height (60), top (0), onDraw ...
    container.add(itemA);
    var itemB = new Moscrif.View("itemB");
    ... width, height (60), top (60), onDraw ...
    container.add(itemB);
find
                      - name
Search for child view, which name is same as name from function's param.
Parameters:
- 
                            nameStringName of the child view to search 
Returns:
Example:
var btnView = new Moscrif.View();
btnView.name = "button";
var imgView = new Moscrif.View();
imgView.name = "image";
app.add(imgView);
// find button view
var button = this.find("button");
// detach button view
button.detach();
init
                      - enableFPS=true
Initialize window object.
Parameters:
- 
                            enableFPS=trueBooleanDefault is false (FPS counting is disabled). 
Example:
var app = new Moscrif.Window();
app.terminate = false;
app.onStart = function()
{
}
app.onProcess = function(sender)
{
    return this.terminate ? 0 : 1;
}
app.init();
app.run();
invalidate
                      - [left]
- [top]
- [right]
- [bottom]
This function ensure redrawing a rectangle, determined by parameters. If no parameters are set, whole object will be redraw. Redrawing manages the function, which is set to onDraw event.
Parameters:
Example:
var app = new Moscrif.Window();
app.terminate = false;
...
app.onProcess = function(sender)
{
    // redraw window every call of onProcess event, usally used at games
    app.invalidate();
    return this.terminate ? 0 : 1;
}
performLayout
() Window
                      
                      Performs (force) layout calculations.
Returns:
removeAll
() chainable
                      
                      Removes all object from the window.
resumeLayout
() Window
                      
                      Resume layer's recalculating.
Returns:
run
() Window chainable
                      
                      Runs the main application loop. This function is blocking.
Returns:
suspendLayout
() Window
                      
                      Pause layer's recalculating. This function is useful when a lot of items are inserted into view in short time. When resumeLayout is called, all items will be inserted at once .
Returns:
Properties
orientation
Symbol
                      
                      This property sets supported device orientations. If there are more supported orientations event onOrientationChanged is called, when device orientation change. Supported are:
- #portrait
- #landscape-left
- #landscape-right
Events
onBackground
                      
                      This event appears, when application moves to background.
Event Payload:
- 
                            senderObjectObject which caused this event. 
onChar
                      
                      This event is raised by release an UNICODE character key.
Event Payload:
- 
                            senderObjectObject which caused this event. 
- 
                            keyIntegerCode from unicode table. 
onDraw
                      
                      This event occurs, when it is necessary to redraw object. onDraw event is usually managed by skin.
Event Payload:
- 
                            senderObjectObject which caused this event. 
- 
                            canvasCanvasCanvas object enabling drawing to the TextView. 
onForeground
                      
                      This event appears, when application moves to foreground.
Event Payload:
- 
                            senderObjectObject which caused this event. 
onKeyPressed
                      
                      This event is raised by press the key.
Event Payload:
- 
                            senderObjectObject which caused this event. 
- 
                            keySymbolPressed key. - #leftSoftKey
- #rightSoftKey
- #home
- #back
- #send
- #end
- #num0 - #num9
- #star - the * key
- #hash - the # key
- #up
- #down
- #left
- #right
- #ok
- #volumeUp
- #volumeDown
- #power
- #camera
 
onKeyReleased
                      
                      This event is raised by release the key.
Event Payload:
- 
                            senderObjectObject which caused this event. 
- 
                            keySymbolPressed key. - #leftSoftKey
- #rightSoftKey
- #home
- #back
- #send
- #end
- #num0 - #num9
- #star - the * key
- #hash - the # key
- #up
- #down
- #left
- #right
- #ok
- #volumeUp
- #volumeDown
- #power
- #camera
 
onOrientationChanged
                      
                      This event is raised by change device orientation.
Event Payload:
- 
                            orientationSymbolNew orientation of device 
Example:
game.onOrientationChanged = function(orientation)
{
    // resize all photos to current orientation
    logI("new orientation is : ", orientation);
}
onPointerDragged
                      
                      Called when touch (click) is moved.
onPointerPressed
                      
                      Called when touch (click) is stared.
onPointerReleased
                      
                      Called when touch (click) is finished.
onProcess
                      
                      Callback function, which is which is called from the object every 25ms.
onQuit
                      
                      This event appears, when application ends - only once during the application life cycle.
Event Payload:
- 
                            senderObjectObject which caused this event. 
onResize
                      
                      Occurs when the control is resized.
onStart
                      
                      This event appears, when application starts - only once during the application life cycle.
Event Payload:
- 
                            senderObjectObject which caused this event. 
