# Titanium.UI.Window

The Window is an empty drawing surface or container.

Availability
0.9
0.9
9.2.0
4.1.0

# Overview

To create a window, use the Titanium.UI.createWindow method or a <Window> Alloy element.

A window is a top-level container which can contain other views. Windows can be opened and closed. Opening a window causes the window and its child views to be added to the application's render stack, on top of any previously opened windows. Closing a window removes the window and its children from the render stack.

Windows contain other views, but in general they are not contained inside other views. There are a few specialized views that manage windows:

By default, windows occupy the entire screen except for the navigation bar, status bar, and in the case of windows contained in tab groups, the tab bar. To take up the entire screen, covering any other UI, specify fullscreen:true when creating the window.

# Pass Context Between Windows

To pass data between windows, use a CommonJS module (opens new window) to save information from one window then retrieve it in another. In the example below, the foo module exposes two methods to store and retrieve an object. The first window of the project loads the foo module and uses the set method to store some data before opening the second window. The second window loads the same module and is able to retrieve the content saved by the first window with the get method.

Note that for Alloy projects, you can simply pass the context as the second argument of the Alloy.createController method, then retrieve the data with the special variable $.args in the controller code.

app/lib/foo.js:

// For a classic Titanium project, save the file to 'Resources/foo.js'
var data = {};
function setData (obj){
    data = obj;
}
function getData () {
    return data;
}

// The special variable 'exports' exposes the functions as public
exports.setData = setData;
exports.getData = getData;

app/views/index.xml:

<Alloy>
    <Window backgroundColor="blue">
        <Label onClick="openWindow">Open the Red Window!</Label>
    </Window>
</Alloy>

app/controllers/index.js:

var foo = require('foo');
foo.setData({foobar: 42});

function openWindow () {
    var win2 = Alloy.createController('win2').getView();
    // For Alloy projects, you can pass context
    // to the controller in the Alloy.createController method.
    // var win2 = Alloy.createController('win2', {foobar: 42}).getView();
    win2.open();
}

$.index.open();

app/views/win2.xml:

<Alloy>
    <Window backgroundColor="red">
        <Label id="label">I am a red window.</Label>
    </Window>
</Alloy>

app/controllers/win2.js:

var foo = require('foo');
$.label.text = foo.getData().foobar;

// For Alloy projects, you can also pass in context
// with the Alloy.createController method and retrieve
// it in the controller code.
// $.label.text = $.args.foobar;

In the user interface, a modal window is a window that blocks the main application UI until the modal window is dismissed. A modal window requires the user to interact with it to resume the normal flow of the application. For example, if an action requires the user to login, the application can present a login window, then after the user is authenticated, the normal flow of the application can be resumed.

To create a modal window, set the modal property to true in the dictionary passed to either the Titanium.UI.createWindow() method or the Window object's open() method.

# Android Behavior

The Android platform does not has the concept of a modal window but instead uses modal dialogs. You are probably looking for a Titanium.UI.AlertDialog or Titanium.UI.OptionDialog and the androidView property rather than a modal window.

However, if you know what you are doing and use modal, Titanium creates a window with a translucent background (if the background properties are not set).

The combination of fullscreen:true and modal:true will not work as expected. If the background window displays the status bar or action bar, it will be visible behind the modal window.

Note that Titanium will allow a non-modal window to open on top of a modal window on Android.

# iOS Behavior

By default, if you do not set a backgroundColor, the modal's background color will be the value set to Titanium.UI.backgroundColor.

The modal window will not show the background window stack even if you make the modal translucent. For fullscreen modals, when the modal appears, the background window stack is removed. For non-fullscreen modals on the iPad, the background will be opaque gray if a background color is not specified.

By default, modal windows appear from the bottom of the screen and slide up. To change the default transition, set the modalTransitionStyle property to a Titanium.UI.iOS.MODAL_TRANSITION_STYLE_* constant in the dictionary passed to the Window object's open() method.

Modal windows should not support orientation modes that the window they are opened over do not support. Doing otherwise may cause bad visual/redraw behavior after the modal is dismissed, due to how iOS manages modal transitions.

Starting with Release 3.1.3, if the orientationModes property of a modal window is undefined, then the orientations supported by this window would be the orientation modes specified by the tiapp.xml with the UISupportedInterfaceOrientations key.

iOS does not allow opening non-modal windows on top of a modal window.

# iPad Features

In addition to full-screen modal windows, iPad supports "Page sheet" and "Form sheet" style windows:

  • Page sheet style windows have a fixed width, equal to the width of the screen in portait mode, and a height equal to the current height of the screen. This means that in portrait mode, the window covers the entire screen. In landscape mode, the window is centered on the screen horizontally.

  • Form sheet style windows are smaller than the screen size, and centered on the screen.

The example below is a modal window using the Form sheet style:

You can create this type of modal window on iPad with the following code snippet:

var win = Ti.UI.createNavigationWindow({
    window: Ti.UI.createWindow({
        title: "Modal Window"
    })
});

win.open({
    modal: true,
    modalTransitionStyle: Ti.UI.iOS.MODAL_TRANSITION_STYLE_FLIP_HORIZONTAL,
    modalStyle: Ti.UI.iOS.MODAL_PRESENTATION_FORMSHEET
});

# Animations

Windows can be animated like a Titanium.UI.View, such as using an animation to open or close a window. The example below creates a window that opens from small to large with a bounce effect. This is done by applying a transformation at initialization time that scales the original size of the window to 0. When the window is opened, a new 2D transformation is applied that will scale the window size from 0 to 110% of it's original size, then, after 1/20th of a second, it is scaled back to it's original size at 100%. This gives the bounce effect during animation.

app/views/index.xml:

<Alloy>
    <Window backgroundColor="blue" onPostlayout="animateOpen" >
        <Label color="orange">Animated Window</Label>
    </Window>
</Alloy>

app/controllers/index.js:

$.index.transform = Titanium.UI.createMatrix2D().scale(0);
$.index.open();

var a = Ti.UI.createAnimation({
    transform : Ti.UI.createMatrix2D().scale(1.1),
    duration : 2000,
});
a.addEventListener('complete', function() {
    $.index.animate({
        transform: Ti.UI.createMatrix2D(),
        duration: 200
    });
});

function animateOpen() {
    $.index.animate(a);
}

Note that to animate an Android window while you open it, you need to follow a specific procedure which is explained below in "Window Transitions in Android".

# iOS Platform Notes

# iOS Transition Animations

iOS contains built-in transition animations when switching between non-modal windows. In the Window's open method, set the transition property to a Titanium.UI.iOS.AnimationStyle constant to use an animation. For example, to flip right-to-left between two windows:

app/views/index.xml:

<Alloy>
    <Window backgroundColor="blue" onOpen="animateOpen">
        <Label id="label">I am a blue window!</Label>
    </Window>
</Alloy>

app/controllers/index.js

function animateOpen() {
    Alloy.createController('win2').getView().open({
        transition: Ti.UI.iOS.AnimationStyle.FLIP_FROM_LEFT
    });
}
$.index.open();

app/views/win2.xml:

<Alloy>
    <Window backgroundColor="red">
        <Label id="label">I am a red window!</Label>
    </Window>
</Alloy>

In the above example, the red window will be animated from the right-to-left over the blue window.

You can create transition animations when opening and closing windows in either a Titanium.UI.iOS.NavigationWindow or Titanium.UI.Tab.

Use the Titanium.UI.iOS.createTransitionAnimation method to specify an animation objects to hide and show the window, then set the newly created TransitionAnimation object to the window's Titanium.UI.Window.transitionAnimation property.

In the example below, the windows are closed by rotating them upside down while simulatenously making them transparent:

app/views/index.xml:

<Alloy>
    <NavigationWindow platform="ios">
        <Window id="redwin" title="Red Window" backgroundColor="red">
            <Button id="button" onClick="openBlueWindow">Open Blue Window</Button>
        </Window>
    </NavigationWindow>
</Alloy>

app/controllers/index.js:

function openBlueWindow(e) {
    var bluewin = Alloy.createController('bluewin').getView();
    $.index.openWindow(bluewin);
}

$.redwin.transitionAnimation = Ti.UI.iOS.createTransitionAnimation({
    duration: 300,
    // The show transition makes the window opaque and rotates it correctly
    transitionTo: {
        opacity: 1,
        duration: 300,
        transform: Ti.UI.createMatrix2D()
    },
    // The hide transition makes the window transparent and rotates it upside down
    transitionFrom: {
        opacity: 0,
        duration: 300 / 2,
        transform: Ti.UI.createMatrix2D().rotate(180),
    }
});

$.index.open();

app/views/bluewin.xml:

<Alloy>
    <Window title="Blue Window" backgroundColor="blue" opacity="0">
        <Button onClick="closeWindow">Close Window</Button>
    </Window>
</Alloy>

app/controllers/bluewin.js:

function closeWindow(){
    $.bluewin.close();
}

$.bluewin.transitionAnimation = Ti.UI.iOS.createTransitionAnimation({
    duration: 300,
    // The show transition makes the window opaque and rotates it correctly
    transitionTo: {
        opacity: 1,
        duration: 300,
        transform: Ti.UI.createMatrix2D()
    },
    // The hide transition makes the window transparent and rotates it upside down
    transitionFrom: {
        opacity: 0,
        duration: 300 / 2,
        transform: Ti.UI.createMatrix2D().rotate(180),
    }
});

$.bluewin.transform = Ti.UI.createMatrix2D().rotate(180);

# Android Platform Notes

# Window Transitions in Android

A window is associated with a new Android Titanium.Android.Activity. The only way to animate the opening or closing of an Activity in Android is to apply an animation resource to it. Passing a Titanium.UI.Animation object as a parameter to Titanium.UI.Window.open or Titanium.UI.Window.close will have no effect.

Instead, in the parameter dictionary you pass to Titanium.UI.Window.open or Titanium.UI.Window.close, you should set the activityEnterAnimation and activityExitAnimation keys to animation resources. activityEnterAnimation should be set to the animation you want to run on the incoming activity, while activityExitAnimation should be set to the animation you want to run on the outgoing activity that you are leaving.

Animation resources are available through the R object. Use either Titanium.Android.R for built-in resources or Titanium.App.Android.R for resources that you package in your application.

As an example, you may wish for the window that you are opening to fade in while the window you are leaving should fade out:

var win2 = Ti.UI.createWindow();
win2.open({
    activityEnterAnimation: Ti.Android.R.anim.fade_in,
    activityExitAnimation: Ti.Android.R.anim.fade_out
});

See the official Android R.anim (opens new window) documentation for information about built-in animations.

For information on creating your own animation resource XML files, see "View Animation (opens new window)" in Android's Resources documentation. After creating an animation resource file, you can place it under platform/android/res/anim in your Titanium project folder and it will be packaged in your app's APK and then available via Titanium.App.Android.R.

# Material design transitions in Android

You can provide transition between common elements among participating activities. For example in a master-detail pattern, clicking on a row item animates the common elements of image, title smoothly into details activity as if they are part of the same scene. This seamless animation is called shared element transition and can be achieved by the following steps.

Say window A is opening window B. Firstly, specify a unique transitionName to the common UI elements between the two windows. Next use addSharedElement method on window B passing the window A common UI element and the transition name. This tells the system which views are shared between windows and performs the transition between them. Note that we specify the UI elements of window A since the system needs the source element and connects the destination element from the shared transition name once window B is created and shown.

For example to transition a title label in window A to a title label in window B.

// Create label in window A with a unique transitionName.
var titleInWinA = new Ti.UI.createLabel({
    text:'Top 10 pics from Mars!',
    left:70, top: 6,
    width:200, height: 30,
    transitionName: 'title'
});
windowA.add(titleInWinA);

// Creating label in window B, note that the same transitionName is used.
var titleInWinB = new Ti.UI.createLabel({
    text:'Top 10 pics from Mars!',
    left:50, top: 10,
    width:200, height: 30,
    transitionName: 'title'
});

// Before opening window B specify the common UI elements.
windowB.addSharedElement(titleInWinA, "title");
windowB.open();

Further you can use activityEnterTransition, activityExitTransition, activityReenterTransition and activityReturnTransition to customize the way activities transition into the scene. These are intended to be used with views set up as "shared elements" via the addSharedElement() method where these views will be moved from window to the other. As of Titanium 8.0.1, you don't have to add views as shared elements to use these transition animations, while in older version of Titanium that was required.

See the official Android Activity Transitions (opens new window) documentation for more information and supported transitons.

# Android "root" Windows

In Android, you may wish to specify that a window which you create (such as the first window) should be considered the root window and that the application should exit when the back button is pressed from that window. This is particularly useful if your application is not using a Tab Group and therefore the splash screen window is appearing whenever you press the back button from your lowest window on the stack.

To indicate that a particular window should cause an application to exit when the back button is pressed, pass exitOnClose: true as one of the creation arguments, as shown here:

var win = Titanium.UI.createWindow({
  title: 'My Root Window',
  exitOnClose: true
});

Starting with Release 3.2.0, the root window's exitOnClose property is set to true by default. Prior to Release 3.2.0, the default value of the property was false for all windows.

# Examples

# Full Screen Window example

Create a fullscreen window with a red background.

var window = Titanium.UI.createWindow({
    backgroundColor:'red'
});
window.open({fullscreen:true});

# Alloy XML Markup

Previous example as an Alloy view.

<Alloy>
    <Window id="win" backgroundColor="red" fullscreen="true" />
</Alloy>

# Properties

# activity READONLY

Availability
0.9

Contains a reference to the Android Activity object associated with this window.

An Activity object is not created until the window is opened. Before the window is opened, activity refers to an empty JavaScript object. You can be set properties on this object, but cannot invoke any Activity methods on it. Once the window is opened, the actual Activity object is created, using any properties set on the JavaScript object. At this point, you can call methods on the activity and access any properties that are set when the activity is created, for example, actionBar.


# activityEnterTransition CREATION ONLY

Availability
5.2.0
activityEnterTransition :Number

The type of transition used when activity is entering.

Activity B's enter transition determines how views in B are animated when A starts B. Applicable for Android 5.0 and above. This transition property will be ignored if animated is set to false. Will also be ignored unless at least 1 view has been assigned to the addSharedElement() method, except on Titanium 8.0.1 and higher where shared elements are no longer required to do transitions.

See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: If not specified uses platform theme transition.


# activityExitTransition CREATION ONLY

Availability
5.2.0
activityExitTransition :Number

The type of transition used when activity is exiting.

Activity A's exit transition determines how views in A are animated when A starts B. Applicable for Android 5.0 and above. This transition property will be ignored if animated is set to false. Will also be ignored unless at least 1 view has been assigned to the addSharedElement() method, except on Titanium 8.0.1 and higher where shared elements are no longer required to do transitions.

See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: If not specified uses platform theme transition.


# activityReenterTransition CREATION ONLY

Availability
5.2.0
activityReenterTransition :Number

The type of transition used when reentering to a previously started activity.

Activity A's reenter transition determines how views in A are animated when B returns to A. Applicable for Android 5.0 and above. This transition property will be ignored if animated is set to false. Will also be ignored unless at least 1 view has been assigned to the addSharedElement() method, except on Titanium 8.0.1 and higher where shared elements are no longer required to do transitions.

See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: If not specified uses `activityExitTransition`.


# activityReturnTransition CREATION ONLY

Availability
5.2.0
activityReturnTransition :Number

The type of transition used when returning from a previously started activity.

Activity B's return transition determines how views in B are animated when B returns to A. Applicable for Android 5.0 and above. This transition property will be ignored if animated is set to false. Will also be ignored unless at least 1 view has been assigned to the addSharedElement() method, except on Titanium 8.0.1 and higher where shared elements are no longer required to do transitions.

See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: If not specified uses `activityEnterTransition`.


# activitySharedElementEnterTransition CREATION ONLY

Availability
5.2.0
activitySharedElementEnterTransition :Number

The type of enter transition used when animating shared elements between two activities.

Activity B's shared element enter transition determines how shared elements animate from A to B. Applicable for Android 5.0 and above. This value will be ignored if animated is set to false. See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: Defaults to android platform's [move](https://github.com/android/platform_frameworks_base/blob/lollipop-release/core/res/res/transition/move.xml) transition.


# activitySharedElementExitTransition CREATION ONLY

Availability
5.2.0
activitySharedElementExitTransition :Number

The type of exit transition used when animating shared elements between two activities.

Activity A's shared element exit transition animates shared elements before they transition from A to B Applicable for Android 5.0 and above. This value will be ignored if animated is set to false. See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: Defaults to android platform's [move](https://github.com/android/platform_frameworks_base/blob/lollipop-release/core/res/res/transition/move.xml) transition.


# activitySharedElementReenterTransition CREATION ONLY

Availability
5.2.0
activitySharedElementReenterTransition :Number

The type of reenter transition used when animating shared elements between two activities.

Activity A's shared element reenter transition animates shared elements after they have transitioned from B to A. Applicable for Android 5.0 and above. This value will be ignored if animated is set to false. See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: Defaults to android platform's [move](https://github.com/android/platform_frameworks_base/blob/lollipop-release/core/res/res/transition/move.xml) transition.


# activitySharedElementReturnTransition CREATION ONLY

Availability
5.2.0
activitySharedElementReturnTransition :Number

The type of return transition used when animating shared elements between two activities.

Activity B's shared element return transition determines how shared elements animate from B to A. Applicable for Android 5.0 and above. This value will be ignored if animated is set to false. See "Material design activity transitions in Android" in the main description of Titanium.UI.Window for more information.

Default: Defaults to android platform's [move](https://github.com/android/platform_frameworks_base/blob/lollipop-release/core/res/res/transition/move.xml) transition.


# autoAdjustScrollViewInsets

Availability
3.1.3
9.2.0
autoAdjustScrollViewInsets :Boolean

Specifies whether or not the view controller should automatically adjust its scroll view insets.

When the value is true, it allows the view controller to adjust its scroll view insets in response to the screen areas consumed by the status bar, navigation bar, toolbar and tab bar.

The default behavior assumes that this is false. Must be specified before opening the window.


# backButtonTitle

Availability
0.9
9.2.0
backButtonTitle :String

Title for the back button. This is only valid when the window is a child of a tab.


# backButtonTitleImage

Availability
0.9
9.2.0
backButtonTitleImage :String | Titanium.Blob

The image to show as the back button. This is only valid when the window is a child of a tab.


# backgroundColor

Availability
0.9
0.9
9.2.0
backgroundColor :String | Titanium.UI.Color

Background color of the window, as a color name or hex triplet.

On Android, to specify a semi-transparent background, set the alpha value using the opacity property before opening the window.

For information about color values, see the "Colors" section of Titanium.UI.

Default: Transparent


# barColor

Availability
8.0.1
0.9
9.2.0
barColor :String | Titanium.UI.Color

Background color for the nav bar, as a color name or hex triplet.

For information about color values, see the "Colors" section of Titanium.UI.


# barImage

Availability
0.9
9.2.0
barImage :String

Background image for the nav bar, specified as a URL to a local image.

The behavior of this API on iOS has changed from version 3.2.0. Previous versions of the SDK created a custom image view and inserted it as a child of the navigation bar. The titanium sdk now uses the native call to set the background image of the navigation bar. You can set it to a 1px transparent png to use a combination of barColor and hideShadow:true.


# bottom

Availability
0.9
0.9
9.2.0
bottom :Number | String

Window's bottom position, in platform-specific units.

On Android, this property has no effect.

Default: 0


# closed READONLY

Availability
9.1.0
9.1.0
9.2.0
closed :Boolean

Determines whether this Window is closed.

Default: true


# exitOnClose

Availability
0.9
4.1.0
exitOnClose :Boolean

Boolean value indicating if the application should exit when the Android Back button is pressed while the window is being shown or when the window is closed programmatically.

Starting in 3.4.2 you can set this property at any time. In earlier releases you can only set this as a createWindow({...}) option.

Default: true if this is the first window launched else false; prior to Release 3.3.0, the default was always false.


# extendEdges

Availability
3.1.3
9.2.0
extendEdges :Array<Number>

An array of supported values specified using the EXTEND_EDGE constants in Titanium.UI.

This is only valid for windows hosted by navigation controllers or tab bar controllers. This property is used to determine the layout of the window within its parent view controller. For example if the window is specified to extend its top edge and it is hosted in a navigation controller, then the top edge of the window is extended underneath the navigation bar so that part of the window is obscured. If the navigation bar is opaque (translucent property on window is false), then the top edge of the window will only extend if includeOpaqueBars is set to true.

The default behavior is to assume that no edges are to be extended. Must be specified before opening the window.


# extendSafeArea CREATION ONLY

Availability
7.5.0
6.3.0
9.2.0
extendSafeArea :Boolean

Specifies whether the screen insets/notches are allowed to overlap the window's content or not.

If set true, then the contents of the window will be extended to fill the whole screen and allow the system's UI elements (such as a translucent status-bar) and physical obstructions (such as the iPhone X rounded corners and top sensor housing) to overlap the window's content. In this case, it is the app developer's responsibility to position views so that they're unobstructed. On Android, you can use the safeAreaPadding property after the window has been opened to layout your content within the insets.

If set false, then the window's content will be laid out within the safe-area and its child views will be unobstructed. For example, you will not need to position a view below the top status-bar.

Read more about the safe-area layout-guide in the Human Interface Guidelines.

Default: `false` on Android, `true` on iOS.


# flagSecure CREATION ONLY

Availability
3.3.0
flagSecure :Boolean

Treat the content of the window as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays.

When the value is true, preventing it from appearing in screenshots or from being viewed on non-secure displays.

Default: false


# focused READONLY

Availability
9.1.0
9.1.0
9.2.0
focused :Boolean

Determines whether this TextArea has focus.

Default: false


# fullscreen

Availability
0.9
0.9
9.2.0
4.1.0
fullscreen :Boolean

Boolean value indicating if the window is fullscreen.

A fullscreen window occupies all of the screen space, hiding the status bar. Must be specified at creation time or in the options dictionary passed to the open method.

On iOS the behavior of this property has changed. Starting from 3.1.3, if this property is undefined then the property is set to the value for UIStatusBarHidden defined in tiapp.xml. If that is not defined it is treated as explicit false. On earlier versions, opening a window with this property undefined would not effect the status bar appearance.

Default: false


# hidesBackButton

Availability
8.0.0
7.5.0
9.2.0
hidesBackButton :Boolean

Set this to true to hide the back button of navigation bar.

When this property is set to true, the navigation window hides its back button.

Default: false


# hidesBarsOnSwipe CREATION ONLY

Availability
6.0.0
9.2.0
hidesBarsOnSwipe :Boolean

Set this to true to hide the navigation bar on swipe.

When this property is set to true, an upward swipe hides the navigation bar and toolbar. A downward swipe shows both bars again. If the toolbar does not have any items, it remains visible even after a swipe.

Default: false


# hidesBarsOnTap CREATION ONLY

Availability
6.0.0
9.2.0
hidesBarsOnTap :Boolean

Set this to true to hide the navigation bar on tap.

When the value of this property is true, the navigation controller toggles the hiding and showing of its navigation bar and toolbar in response to an otherwise unhandled tap in the content area.

Default: false


# hidesBarsWhenKeyboardAppears CREATION ONLY

Availability
6.0.0
9.2.0
hidesBarsWhenKeyboardAppears :Boolean

Set this to true to hide the navigation bar when the keyboard appears.

When this property is set to true, the appearance of the keyboard causes the navigation controller to hide its navigation bar and toolbar.

Default: false


# hideShadow

Availability
3.2.0
9.2.0
hideShadow :Boolean

Set this to true to hide the shadow image of the navigation bar.

This property is only honored if a valid value is specified for the barImage property.

Default: false


# hidesSearchBarWhenScrolling

Availability
8.1.0
9.2.0
hidesSearchBarWhenScrolling :Boolean

A Boolean value indicating whether the integrated search bar is hidden when scrolling any underlying content.

When the value of this property is true, the search bar is visible only when the scroll position equals the top of your content view. When the user scrolls down, the search bar collapses into the navigation bar. Scrolling back to the top reveals the search bar again. When the value of this property is false, the search bar remains regardless of the current scroll position. You must set showSearchBarInNavBar or showSearchBarInNavBar property for this property to have any effect.

Default: true


# homeIndicatorAutoHidden

Availability
7.3.0
9.2.0
homeIndicatorAutoHidden :Boolean

Boolean value indicating whether the system is allowed to hide the visual indicator for returning to the Home screen.

Set this value true, if you want the system to determine when to hide the indicator. Set this value false, if you want the indicator shown at all times. The system takes your preference into account, but setting true is no guarantee that the indicator will be hidden.

Default: false


# includeOpaqueBars

Availability
3.1.3
9.2.0
includeOpaqueBars :Boolean

Specifies if the edges should extend beyond opaque bars (navigation bar, tab bar, toolbar).

By default edges are only extended to include translucent bars. However if this is set to true, then edges are extended beyond opaque bars as well.

The default behavior assumes that this is false. Must be specified before opening the window.


# largeTitleDisplayMode

Availability
6.3.0
9.2.0
largeTitleDisplayMode :Number

The mode to use when displaying the title of the navigation bar.

Automatically use the large out-of-line title based on the state of the previous item in the navigation bar. An item with largeTitleDisplayMode = Ti.UI.iOS.LARGE_TITLE_DISPLAY_MODE_AUTOMATIC will show or hide the large title based on the request of the previous navigation item. If the first item pushed is set to Automatic, then it will show the large title if the navigation bar has largeTitleEnabled = true.

Default: Titanium.UI.iOS.LARGE_TITLE_DISPLAY_MODE_AUTOMATIC


# largeTitleEnabled

Availability
6.3.0
9.2.0
largeTitleEnabled :Boolean

A Boolean value indicating whether the title should be displayed in a large format.

When set to true, the navigation bar will use a larger out-of-line title view when requested by the current navigation item. To specify when the large out-of-line title view appears, see largeTitleDisplayMode.

Default: false


# left

Availability
0.9
0.9
9.2.0
left :Number | String

Window's left position, in platform-specific units.

On Android, this property has no effect.

Default: 0


# leftNavButton

Availability
0.9
9.2.0
leftNavButton :Titanium.UI.View

View to show in the left nav bar area.

In an Alloy application you can specify this property with a <LeftNavButton> element inside the <Window> element, for example:

<Alloy>
    <TabGroup>
        <Tab>
            <Window class="container">
                <LeftNavButton platform=ios>
                    <Button title="Back" onClick="closeWindow" />
                </LeftNavButton>
            </Window>
        </Tab>
    </TabGroup>
</Alloy>

# leftNavButtons

Availability
3.3.0
9.2.0
leftNavButtons :Array<Titanium.UI.View>

An Array of views to show in the left nav bar area.


Availability
0.9
0.9
9.2.0
modal :Boolean

Indicates to open a modal window or not.

Set to true to create a modal window.

Must be specified at creation time or in the dictionary passed to the open method.

In the user interface, a modal window is a window that blocks the main application UI until the modal window is dismissed. A modal window requires the user to interact with it to resume the normal flow of the application.

See the "Modal Windows" section for platform-specific information.

Default: false


Availability
0.9
0.9
9.2.0
navBarHidden :Boolean

Hides the navigation bar (true) or shows the navigation bar (false).

# iOS Platform Notes

Since Titanium SDK 6.0.0, you can use this property to hide and show the property as well.

Using this property, the navigation bar will be hidden or shown animated by default. Please note that this property will only take effect if the window is used inside a Titanium.UI.NavigationWindow and will be ignored otherwise. If you want to hide or show the navigation without an animation, use t he methods showNavBar and hideNavBar with the second parameter to specify the animation:

// "myWindow" is a Ti.UI.Window inside a Ti.UI.NavigationWindow
myWindow.hideNavBar(true, {animated: false});

# Android Platform Notes

Since Release 3.3.0, due to changes to support the appcompat library, this property has no effect. By default, the action bar is always displayed. To hide the action bar, see the Android Action Bar guide.

Default: false


Availability
7.3.0
9.2.0
navigationWindow :Titanium.UI.NavigationWindow

The Titanium.UI.NavigationWindow instance hosting this window.

Returns the navigation window that hosts this window. Returns null if the window is not hosted by a navigation window.


Availability
3.1.3
9.2.0
navTintColor :String | Titanium.UI.Color

The tintColor to apply to the navigation bar.

This property is a direct correspondant of the tintColor property of NavigationBar on iOS.

Default: null


# onBack

Availability
0.9
onBack :Callback<void>

Callback function that overrides the default behavior when the user presses the Back button.

This was separated from the androidback event. You need to define this callback if you explicitly want to override the back button behavior.


# opacity

Availability
0.9
0.9
9.2.0
opacity :Number

The opacity from 0.0-1.0.

iOS notes: For modal windows that cover the previous window, the previous window is removed from the render stack after the modal window finishes opening. If the modal window is semi-transparent, the underlying window will be visible during the transition animation, but disappear as soon as the animation is completed. (In general all modal windows cover the previous window, except for iPad modal windows using the Page sheet or Form sheet style.)

Android notes: If you set any of windowSoftInputMode, fullscreen, or navBarHidden, and you wish to use the opacity property at any time during the window's lifetime, be sure to set an opacity value before opening the window. You can later change that value -- and you can set it to 1 for full opacity if you wish -- but the important thing is that you set it to a value before opening the window if you will want to set it at any time during the window's lifetime.

The technical reason for this is that if the opacity property is present (i.e., has been set to something) and a new Android Activity is created for the window, then a translucent theme will be used for the Activity. Window transparency (opacity values below 1) will only work in Android if the Activity's theme is translucent, and Titanium only uses a translucent theme for an Activity if you set an opacity property before opening the window. Additionally, do not use opacity and fullscreen: true together, because translucent themes in Android cannot hide the status bar. Finally, if you do set the opacity property, be sure to also set a backgroundImage or backgroundColor property as well, unless you want the window to be completely transparent.


# orientation READONLY

Availability
0.9
3.0.0
9.2.0
orientation :Number

Current orientation of the window.

To determine the current orientation of the device, see orientation, instead.

See the discussion of the orientationModes property for more information on how the screen orientation is determined.


# orientationModes

Availability
0.9
0.9
9.2.0
orientationModes :Array<Number>

Array of supported orientation modes, specified using the orientation constants defined in Titanium.UI.

Note: Using the orientationModes property to force the orientation of non-modal windows is considered a bad practice and will not be supported, including forcing the orientation of windows inside a NavigationWindow or TabGroup.

To restrict this window to a certain set of orientations, specify one or more of the orientation constants LANDSCAPE_LEFT, LANDSCAPE_RIGHT, PORTRAIT, UPSIDE_PORTRAIT.

orientationModes must be set before opening the window.

To determine the current orientation of the window, see orientation. To determine the current orientation of the device, see orientation. To be notified when the device's current orientation changes, add a listener for the orientationchange event.

# Android Orientation Modes

On Android, orientation behavior is dependent on the Android SDK level of the device itself. Devices running Android 2.3 and above support "sensor portait mode" and "sensor landscape mode," in these modes, the device is locked into either a portrait or landscape orientation, but can switch between the normal and reverse orientations (for example, between PORTRAIT and UPSIDE_PORTRAIT).

In addition, the definition of portrait or landscape mode can vary based on the physical design of the device. For example, on some devices LANDSCAPE_LEFT represents the top of the device being at the 270 degree position but other devices may (based on camera position for example) treat this position as LANDSCAPE_RIGHT. In general, applications for Android that need to be aware of orientation should try and limit their orientation logic to handling either portrait or landscape rather than worrying about the reverse modes. This approach will allow the orientation modes to adopt a more natural feel for the specific device.

The following list breaks down the orientation behavior on Android based on the contents of the orientationModes array:

  1. Empty array. Enables orientation to be fully controlled by the device sensor.

  2. Array includes one or both portrait modes and one or both landscape modes. Enables full sensor control (identical to an empty array).

  3. Array contains PORTRAIT and UPSIDE_PORTRAIT. On Android 2.3 and above, enables sensor portrait mode. This means the screen will shift between both portrait modes according to the sensor inside the device.

    On Android versions below 2.3, locks screen orientation in normal portrait mode.

  4. Array contains LANDSCAPE_LEFT and LANDSCAPE_RIGHT. On Android 2.3 and above, enables sensor landscape mode. This means the screen will shift between both landscape modes according to the sensor inside the device.

    On Android versions below 2.3, locks screen orientation in normal landscape mode.

  5. Array contains only PORTRAIT. Locks screen orientation to normal portrait mode.

  6. Array contains only LANDSCAPE_LEFT. Locks screen orientation to normal landscape mode.

  7. Array contains only UPSIDE_PORTRAIT. On Android 2.3 and above, locks screen in reverse portrait mode.

    On Android versions below 2.3, results are undefined.

  8. Array contains only LANDSCAPE_RIGHT. On Android 2.3 and above, locks screen in reverse landscape mode.

    On Android versions below 2.3, results are undefined.

Default: empty array


Availability
0.9
0.9
9.2.0
right :Number | String

Window's right position, in platform-specific units.

On Android, this property has no effect.

Default: 0


# rightNavButton

Availability
0.9
9.2.0
rightNavButton :Titanium.UI.View

View to show in the right nav bar area.

In an Alloy application you can specify this property with a <RightNavButton> element in the <Window> element, for example:

<Alloy>
    <TabGroup>
        <Tab>
            <Window class="container">
                <RightNavButton platform=ios>
                    <Button title="Back" onClick="closeWindow" />
                </RightNavButton>
            </Window>
        </Tab>
    </TabGroup>
</Alloy>

# rightNavButtons

Availability
3.3.0
9.2.0
rightNavButtons :Array<Titanium.UI.View>

An Array of views to show in the right nav bar area.


# safeAreaPadding READONLY

Availability
7.5.0
8.0.0
9.2.0
safeAreaPadding :Padding

The padding needed to safely display content without it being overlapped by the screen insets and notches.

When setting extendSafeArea to true, the system's insets such as a translucent status bar, translucent navigation bar, and/or camera notches will be allowed to overlay on top of the window's content. In this case, it is the app developer's responsibility to prevent these insets from overlapping key content such as buttons. This property provides the amount of space needed to be added to the left, top, right, and bottom edges of the window root view to do this.

This property won't return values greater than zero until the window has been opened. It is recommended that you read this property via a postlayout event listener since the padding values can change when when the app's orientation changes or when showing/hiding the action bar.

If the extendSafeArea property is set false, then the returned padding will be all zeros since the root content will be positioned between all insets.

Below is an example on how to set up a safe-area view container using this property.

// Set up a window with a translucent top status bar and translucent nav bar.
// This will only work on Android 4.4 and newer OS versions.
var win = Ti.UI.createWindow({
    extendSafeArea: true,
    theme: 'Theme.Titanium.NoTitleBar',
    windowFlags: Ti.UI.Android.FLAG_TRANSLUCENT_NAVIGATION | Ti.UI.Android.FLAG_TRANSLUCENT_STATUS
});

// Set up a safe-area view to be layed out between the system insets.
// You should use this as a container for child views.
var safeAreaView = Ti.UI.createView({
    backgroundColor: 'green'
});
win.add(safeAreaView);
win.addEventListener('postlayout', function() {
    // Update the safe-area view's dimensions after every 'postlayout' event.
    safeAreaView.applyProperties(win.safeAreaPadding);
});

// Open the window.
win.open();

# shadowImage

Availability
3.2.0
9.2.0
shadowImage :String

Shadow image for the navigation bar, specified as a URL to a local image..

This property is only honored if a valid value is specified for the barImage property.


# splitActionBar CREATION ONLYDEPRECATED

Availability
3.6.0
splitActionBar :Boolean

DEPRECATED SINCE 6.2.0

Deprecated in AppCompat theme. The same behaviour can be achived by using Toolbar.

Boolean value to enable split action bar.

splitActionBar must be set before opening the window. This property indicates if the window should use a split action bar


# statusBarStyle

Availability
3.1.3
9.2.0
statusBarStyle :Number

The status bar style associated with this window.

Sets the status bar style when this window has focus. This is now the recommended way to control the status bar style on the application.

If this value is undefined, the value is set to UIStatusBarStyle defined in tiapp.xml. If that is not defined it defaults to DEFAULT.


# sustainedPerformanceMode

Availability
7.0.0
sustainedPerformanceMode :Boolean

Maintain a sustainable level of performance.

Performance can fluctuate dramatically for long-running apps, because the system throttles system-on-chip engines as device components reach their temperature limits. This fluctuation presents a moving target for app developers creating high-performance, long-running apps.

Setting this feature to true will set sustained performance mode for the corresponding window. If property is undefined then it defaults to false.

Note: This feature is only available on supported devices. The functionality is experimental and subject to change in future releases. See Android docs for further info.


# swipeToClose

Availability
5.2.0
9.2.0
swipeToClose :Boolean

Boolean value indicating if the user should be able to close a window using a swipe gesture.

If false the user will not be able to swipe from the left edge of the window to close it. Note: This property is only used for a window being embedded in a Titanium.UI.Tab or Titanium.UI.NavigationWindow. It is enabled by default.

Default: true


# tabBarHidden

Availability
0.9
9.2.0
tabBarHidden :Boolean

Boolean value indicating if the tab bar should be hidden.

tabBarHidden must be set before opening the window.

This property is only valid when the window is the child of a tab.


# theme CREATION ONLY

Availability
3.4.0
theme :String

Name of the theme to apply to the window.

Set the theme of the window. It can be either a built-in theme or a custom theme.


# title

Availability
0.9
0.9
9.2.0
4.1.0
title :String

Title of the window.


# titleAttributes

Availability
3.2.0
9.2.0
titleAttributes :titleAttributesParams

Title text attributes of the window.

Use this property to specify the color, font and shadow attributes of the title.


# titleControl

Availability
0.9
9.2.0
titleControl :Titanium.UI.View

View to show in the title area of the nav bar.

In an Alloy application you can specify this property using a <TitleControl> element inside <Window>, for example:

<Alloy>
    <Window>
        <RightNavButton>
            <Button title="Back" />
        </RightNavButton>
        <LeftNavButton>
            <Button title="Back" />
        </LeftNavButton>
        <TitleControl>
            <View backgroundColor="blue" height="100%" width="100%"></View>
        </TitleControl>
    </Window>
</Alloy>

# titleid

Availability
0.9
0.9
9.2.0
4.1.0
titleid :String

Key identifying a string from the locale file to use for the window title.

Only one of title or titleid should be specified.


# titleImage

Availability
0.9
9.2.0
titleImage :String

Image to show in the title area of the nav bar, specified as a local file path or URL.


# titlePrompt

Availability
0.9
9.2.0
titlePrompt :String

Title prompt for the window.


# titlepromptid

Availability
0.9
9.2.0
titlepromptid :String

Key identifying a string from the locale file to use for the window title prompt.

Only one of titlePrompt or titlepromptid should be specified.


# toolbar

Availability
0.9
9.2.0
toolbar :Array<Titanium.UI.View>

Array of button objects to show in the window's toolbar.

The toolbar is only shown when the window is inside a Titanium.UI.NavigationWindow. To display a toolbar when a window is not inside a NavigationWindow, add an instance of a Titanium.UI.iOS.Toolbar to the window.

To customize the toolbar, use the setToolbar method.

Since Alloy 1.6.0, you can specify this property using the <WindowToolbar> element as a child of a <Window> element, for example:

<Alloy>
    <NavigationWindow>
        <Window>
            <WindowToolbar>
                <Button id="send" title="Send" style="Ti.UI.iOS.SystemButtonStyle.DONE" />
                <FlexSpace/>
                <Button id="camera" systemButton="Ti.UI.iOS.SystemButton.CAMERA" />
                <FlexSpace/>
                <Button id="cancel" systemButton="Ti.UI.iOS.SystemButton.CANCEL" />
            </WindowToolbar>
        </Window>
    </NavigationWindow>
</Alloy>

# top

Availability
0.9
0.9
9.2.0
top :Number | String

Window's top position, in platform-specific units.

On Android, this property has no effect.

Default: 0


# transitionAnimation

Availability
3.2.0
9.2.0
transitionAnimation :Titanium.Proxy

Use a transition animation when opening or closing windows in a Titanium.UI.NavigationWindow or Titanium.UI.Tab.

Create the transition animation using the createTransitionAnimation method.


# translucent

Availability
0.9
9.2.0
translucent :Boolean

Boolean value indicating if the nav bar is translucent.

Default: true on iOS7 and above, false otherwise.


# windowFlags CREATION ONLY

Availability
3.3.0
windowFlags :Number

Additional flags to set on the Activity Window.

Sets flags such as FLAG_TRANSLUCENT_NAVIGATION and FLAG_TRANSLUCENT_STATUS. When using multiple flags, you must bitwise-or them together.

See WindowManager.LayoutParams for list of additional flags that you can assign to this property. You can assign these Java flags to this property by using their numeric constant.

Setting fullscreen to true automatically sets the WindowManager.LayoutParams.FLAG_FULLSCREEN flag. Setting flagSecure to true automatically sets the WindowManager.LayoutParams.FLAG_SECURE flag.


# windowPixelFormat

Availability
1.8.0
windowPixelFormat :Number

Set the pixel format for the Activity's Window.

For more information on pixel formats, see Android SDK Window.setFormat


# windowSoftInputMode CREATION ONLY

Availability
0.9
windowSoftInputMode :Number

Determines whether a window's soft input area (ie software keyboard) is visible as it receives focus and how the window behaves in order to accomodate it while keeping its contents in view.

In order for this property to take effect on an emulator, its Android Virtual Device (AVD) must be configured with the Keyboard Support setting set to No. Note that it is always recommended to test an application on a physical device to understand its true behavior.

This property is capable of representing two settings from the soft input visibility constatns and soft input adjustment constants using the bitwise OR operation.

Note that in JavaScript, bitwise OR is achieved using the single pipe operand. See the example for a demonstration.

For more information, see the official Android Developers website API Reference for Window.setSoftInputMode.

# Methods

# addSharedElement

Availability
5.2.0
addSharedElement(view, transitionName) void

Adds a common UI element to participate in window transition animation.

Available from Android 5.0. Use the current window's UI element that is contextually shared with the other window.

Parameters

Name Type Description
view Titanium.UI.View

The shared view from the current window.

transitionName String

The assigned common transition name of UI elements in both windows.

Returns

Type
void

# close

Availability
0.9
0.9
9.2.0
4.1.0
close([params]) Promise<any>

Closes the window.

Android only supports the argument type closeWindowParams.

Parameters

Name Type Description
params Titanium.UI.Animation | Dictionary<Titanium.UI.Animation> | closeWindowParams

Animation or display properties to use when closing the window.

Returns

Starting in SDK 10.0.0, this method returns a Promise that will be resolved once the window is closed, akin to adding a one-time listener for the close event. If the window fails to close (for example, because it was not yet open) the Promise will be rejected.

Type
Promise<any>

# hideNavBar

Availability
0.9
9.2.0
hideNavBar([options]) void

Hides the navigation bar.

If the window is not displayed in a Titanium.UI.NavigationWindow, this method has no effect.

Parameters

Name Type Description
options AnimatedOptions

Options dictionary supporting a single animated boolean property to determine whether the navigation bar will be animated (default) while being hidden. Note that the default here is equivalent to { animated: true }

Returns

Type
void

# hideTabBar

Availability
0.9
9.2.0
hideTabBar() void

Hides the tab bar. Must be called before opening the window.

To hide the tab bar when opening a window as a child of a tab, call hideTabBar or set tabBarHidden to true before opening the window.

If the window is not a child of a tab, this method has no effect.

Returns

Type
void

# hideToolbar

Availability
5.4.0
9.2.0
hideToolbar([options]) void

Makes the bottom toolbar invisible.

If the window is not displayed in a Titanium.UI.NavigationWindow, this method has no effect. Note: This method is only intended to work with toolbars that are created using setToolbar. It will not have any effect on toolbars added manually to the window.

Parameters

Name Type Description
options AnimatedOptions

Options dictionary supporting a single animated boolean property to determine whether the toolbar will be animated (default) while being hidden. Note that the default here is equivalent to { animated: true }

Returns

Type
void

# open

Availability
0.9
0.9
9.2.0
4.1.0
open([params]) Promise<any>

Opens the window.

Parameters

Name Type Description
params openWindowParams

Animation or display properties to use when opening the window.

Returns

Starting in SDK 10.0.0, this method returns a Promise that will be resolved once the window is opened, akin to adding a one-time listener for the open event. If the window fails to open (for example, because it is already opened or opening) the Promise will be rejected.

Type
Promise<any>

# removeAllSharedElements

Availability
5.2.0
removeAllSharedElements() void

Clears all added shared elements.

Available from Android 5.0. Use this method to clear all shared elements. This will not remove the views from view hierarchy.

Returns

Type
void

# setToolbar

Availability
0.9
9.2.0
setToolbar(items[, params]) void

Sets the array of items to show in the window's toolbar.

Parameters

Name Type Description
items Array<Object>

Array of button objects to show in the window's toolbar.

params windowToolbarParam

Parameters to control the toolbar appearance.

Returns

Type
void

# showNavBar

Availability
0.9
9.2.0
showNavBar([options]) void

Makes the navigation bar visible.

If the window is not displayed in a Titanium.UI.NavigationWindow, this method has no effect.

Parameters

Name Type Description
options AnimatedOptions

Options dictionary supporting a single animated boolean property to determine whether the navigation bar will be animated (default) while being shown. Note that the default here is equivalent to { animated: true }

Returns

Type
void

# showToolbar

Availability
5.4.0
9.2.0
showToolbar([options]) void

Makes the bottom toolbar visible.

If the window is not displayed in a Titanium.UI.NavigationWindow, this method has no effect. Note: This method is only intended to work with toolbars that are created using setToolbar. It will not have any effect on toolbars added manually to the window.

Parameters

Name Type Description
options AnimatedOptions

Options dictionary supporting a single animated boolean property to determine whether the toolbar will be animated (default) while being shown. Note that the default here is equivalent to { animated: true }

Returns

Type
void

# Events

# focus

Availability