A Popover is used to manage the presentation of content in a popover.
A popover is created using the Titanium.UI.iPad.createPopover method or <Popover>
Alloy element.
Popovers are used to present information temporarily, but in a way that does not take over the entire screen in the way that a modal view does. The popover content is layered on top of the existing content in a special type of window. The popover remains visible until the user taps outside of the popover window or it is explicitly dismissed.
Do not add top-level view containers, such as a SplitWindow
or TabGroup
, to a popover.
Adding top-level view containers may have unintended side effects. See the contentView
property for more information.
In this example, we create a simple popover and position it near the button.
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var button = Ti.UI.createButton({title: 'Open Popover!'});
button.addEventListener('click', function(e){
popover.show({ view: button });
})
win.add(button);
var rightButton = Ti.UI.createButton({title: 'Robin'});
rightButton.addEventListener('click', function(e){
alert("But green's the color of spring.");
});
var contentWindow = Ti.UI.createWindow({
rightNavButton: rightButton,
title: 'Kermit'
});
contentWindow.add(Ti.UI.createLabel({text: "It's not easy being green."}));
var popover = Ti.UI.iPad.createPopover({
backgroundColor: 'green',
contentView: Ti.UI.iOS.createNavigationWindow({
width: 250,
height: 100,
window: contentWindow
})
});
win.open();
Previous example as an Alloy project.
app/views/index.xml
:
<Alloy>
<Window>
<Button id="button" onClick="openPopover">Open Popover!</Button>
</Window>
</Alloy>
app/controllers/index.js
:
function openPopover() {
var popover = Alloy.createController('popover').getView();
popover.show({view:$.button});
};
$.index.open();
app/views/popover.xml
:
<Alloy>
<Popover backgroundColor='green'>
<ContentView>
<NavigationWindow height='100' width='250'>
<Window title='Kermit'>
<RightNavButton onClick="showAlert" title="Robin" />
<Label>It's not easy being green.</Label>
</Window>
</NavigationWindow>
</ContentView>
</Popover>
</Alloy>
app/controllers/popover.js
:
function showAlert(e) {
alert('But green is the color of spring.');
};
// Prior to Alloy 1.1.0, the rightNavButton property was set in the controller.
// var button = Ti.UI.createButton({title: 'Robin'});
// button.addEventListener('click', showAlert);
// $.popover.rightNavButton = button;
The name of the API that this proxy corresponds to.
The name of the API that this proxy corresponds to.
The value of this property is the fully qualified name of the API. For example, Button
returns Ti.UI.Button
.
Indicates the arrow direction of the popover.
Indicates the arrow direction of the popover.
Use this property to indicate the popover arrows to use. You can bitwise-OR the constant values together.
Do not set this property to Titanium.UI.iPad.POPOVER_ARROW_DIRECTION_UNKNOWN.
This API can be assigned the following constants:
Sets the background color of the popover.
It is recommended to set this property to colorize the whole popover instead of only its content view.
Default: undefined (behaves as transparent)
Overrides: Titanium.UI.View.backgroundColor
Disabled background color of the view, as a color name or hex triplet.
For information about color values, see the "Colors" section of Titanium.UI.
Default: Same as the normal background color of this view.
Disabled background image for the view, specified as a local file path or URL.
Default: If `backgroundDisabledImage` is undefined, and the normal background image `backgroundImage` is set, the normal image is used when this view is disabled.
Focused background color of the view, as a color name or hex triplet.
For information about color values, see the "Colors" section of Titanium.UI.
For normal views, the focused color is only used if focusable
is true
.
Default: Same as the normal background color of this view.
Focused background image for the view, specified as a local file path or URL.
For normal views, the focused background is only used if focusable
is true
.
Default: If `backgroundFocusedImage` is undefined, and the normal background image `backgroundImage` is set, the normal image is used when this view is focused.
Selected background color of the view, as a color name or hex triplet.
For information about color values, see the "Colors" section of Titanium.UI.
focusable
must be true for normal views.
Default: Background color of this view.
Selected background image url for the view, specified as a local file path or URL.
For normal views, the selected background is only used if focusable
is true
.
Default: If `backgroundSelectedImage` is undefined, and the normal background image `backgroundImage` is set, the normal image is used when this view is selected.
Indicates if the proxy will bubble an event to its parent.
Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.
Default: true
View to use for the popover content. Must be set before calling the show()
method.
Set this property to any Titanium.UI.View object, including a Titanium.UI.Window or Titanium.UI.iOS.NavigationWindow object.
This property does not support the Titanium.UI.iPad.SplitWindow or Titanium.UI.TabGroup objects.
When this property is set to a valid object, the popover does not include the navigation controller unless it is set to a Titanium.UI.iOS.NavigationWindow object.
In an Alloy application, you can specify this property as a <ContentView>
child element
of the <Popover>
element:
<Alloy>
<Popover>
<ContentView>
<Window title="Popover">
<Label>Popover!</Label>
</Window>
</ContentView>
</Popover>
</Alloy
Base elevation of the view relative to its parent in pixels.
Requires: Android 5 and later
The elevation of a view determines the appearance of its shadow. Higher elevations produce larger and softer shadows.
Note: The elevation
property only works on Titanium.UI.View
objects.
Many Android components have a default elevation that cannot be modified.
For more information, see
Google design guidelines: Elevation and shadows.
Whether view should be focusable while navigating with the trackball.
Default: false
Height of the popover.
deprecated since 3.4.2
This property is deprecated. Set the height on the contentView property instead.
Defaults to: If undefined, defaults to either Titanium.UI.FILL or Titanium.UI.SIZE depending on the view. See "View Types and Default Layout Behavior" in Transitioning to the New UI Layout System.
Can be either a float value or a dimension string (for example, '50%' or '40dp'). Can also be one of the following special values:
SIZE
or
FILL
constants if it is necessary to set the view's behavior explicitly.This is an input property for specifying the view's height dimension. To determine the view's size once rendered, use the rect or size properties.
This API can be assigned the following constants:
Overrides: Titanium.UI.View.height
Determines whether to keep the device screen on.
When true
the screen will not power down. Note: enabling this feature will use more
power, thereby adversely affecting run time when on battery.
Default: false
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.
If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.
When on, animate call overrides current animation if applicable.
If this property is set to false, the animate call is ignored if the view is currently being animated.
Default: undefined but behaves as false
Passthrough views to use when the popover is shown.
Passthrough views to use when the popover is shown.
Specify view objects that the user can interact with while the popover is open. While interacting with these view, the popover will not be dismissed.
The preview context used in the 3D-Touch feature "Peek and Pop".
Requires: iOS 9.0 and later
Preview context to present the "Peek and Pop" of a view. Use an configured instance of Titanium.UI.iOS.PreviewContext here.
Note: This property can only be used on devices running iOS9 or later and supporting 3D-Touch. It is ignored on older devices and can manually be checked using Titanium.UI.iOS.forceTouchSupported.
Clockwise 2D rotation of the view in degrees.
Clockwise 2D rotation of the view in degrees.
Translation values are applied to the static post layout value.
Clockwise rotation of the view in degrees (x-axis).
Clockwise rotation of the view in degrees (x-axis).
Translation values are applied to the static post layout value.
Clockwise rotation of the view in degrees (y-axis).
Clockwise rotation of the view in degrees (y-axis).
Translation values are applied to the static post layout value.
Scaling of the view in x-axis in pixels.
Scaling of the view in x-axis in pixels.
Translation values are applied to the static post layout value.
Scaling of the view in y-axis in pixels.
Scaling of the view in y-axis in pixels.
Translation values are applied to the static post layout value.
Determines keyboard behavior when this view is focused.
This API can be assigned the following constants:
Default: Titanium.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS
Title of the navigation area of the popover.
deprecated since 3.4.2
This property is no longer supported.
Ignored when contentView is set.
A material design visual construct that provides an instantaneous visual confirmation of touch point.
Requires: Android 5.0 and later
This is an opt-in feature available from Android Lollipop. Touch feedback is applied only if the backgroundColor is a solid color.
Default: false
Optional touch feedback ripple color. This has no effect unless touchFeedback
is true.
Requires: Android 5.0 and later
Default: Theme provided color.
A name to identify this view in activity transition.
Requires: Android 5 and later
Name should be unique in the View hierarchy.
Horizontal location of the view relative to its left position in pixels.
Horizontal location of the view relative to its left position in pixels.
Translation values are applied to the static post layout value.
Vertical location of the view relative to its top position in pixels.
Vertical location of the view relative to its top position in pixels.
Translation values are applied to the static post layout value.
Depth of the view relative to its elevation in pixels.
Requires: Android 5 and later
Translation values are applied to the static post layout value.
Width of the popover.
deprecated since 3.4.2
This property is deprecated. Set the width on the contentView property instead.
Defaults to: If undefined, defaults to either Titanium.UI.FILL or Titanium.UI.SIZE depending on the view. See "View Types and Default Layout Behavior" in Transitioning to the New UI Layout System.
Can be either a float value or a dimension string (for example, '50%' or '40dp'). Can also be one of the following special values:
SIZE
or
FILL
constants if it is necessary to set the view's behavior explicitly.This is an input property for specifying the view's width dimension. To determine the view's size once rendered, use the rect or size properties.
This API can be assigned the following constants:
Overrides: Titanium.UI.View.width
Adds a child to the popover.
This method has been removed since 3.4.2
Use the <Titanium.UI.iPad.Popover.contentView> property to modify the content of the popover.
The child view is added as the last child in this view's hierarchy.
Although all views inherit from Titanium.UI.View, not all views are capable of containing other views. In particular:
The following views are not intended to act as containers that can hold other views:
Adding children to the these views may be supported on some platforms, but is not guaranteed to work across platforms. Where it is supported, it may not work as expected.
For maximum portability, these views should be treated as if they do not support children.
Instead of adding children to these views, applications can positon other views as
siblings. For example, instead of adding a button as a child of a WebView
, you can add
the button to the web view's parent such that it appears on top of the web view.
A few view objects act as special-purpose containers--that is, they only manage
certain types of children, and many of them support a special means of adding
these children, instead of the general add
method. These containers include:
ButtonBar and TabbedBar are designed
to hold their own internally-created buttons, assigned by adding strings to the "labels" array.
Views added using the add
method are displayed on top of these buttons.
Picker. Can only hold PickerRows
and PickerColumns
, which
are added using the add
method. Adding other types of views to a Picker
is not
supported.
TableView is a specialized container for
TableViewSection
and TableViewRow
objects. These objects must be
added using the properties and methods that TableView
provides
for adding and removing sectons and rows.
On some platforms, it is possible to add arbitrary child views to a table view
using the add
method. However, this is not guaranteed to work on all platforms,
and in general, should be avoided.
TableViewSection is a specialized container
for TableViewRow
objects, which are added using the add
method. The add
method
on TableViewSection
can only be used to add TableViewRow
objects.
Toolbar is designed to hold buttons and certain
other controls, added to its items
array. Views added using the add
method are
displayed on top of the controls in the items
array.
The Tab
, TabGroup
, NavigationWindow
and SplitWindow
objects are
special containers that manage windows. These are discussed in the
"Top-Level Containers" section.
There are certain top-level containers that are not intended to be added as the children of other views. These top-level containers include Titanium.UI.Window, Titanium.UI.iPad.SplitWindow, Titanium.UI.iOS.NavigationWindow, and Titanium.UI.TabGroup. Other types of views must be added to a top-level container in order to be displayed on screen.
The special containers Titanium.UI.iOS.NavigationWindow,
Titanium.UI.iPad.SplitWindow, Titanium.UI.Tab, and
Titanium.UI.TabGroup manage windows.
These managed windows may be referred to as children of the
container, but they are not added using the add
method.
Tab
is another kind of special container: it is not itself a top-level container,
but can only be used within a TabGroup
. You cannot add
a Tab
to an arbitrary
container.
View to add to this view's hierarchy.
You may pass an array of views, e.g. view.add([subview1, subview2]
.
Overrides: Titanium.UI.View.add
Adds the specified callback as an event listener for the named event.
Name of the event.
Callback function to invoke when the event is fired.
Applies the properties to the proxy.
Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.
A dictionary of properties to apply.
Finishes a batch update of the View's layout properties and schedules a layout pass of the view tree.
deprecated since 3.0.0
Use the <Titanium.Proxy.applyProperties> method to batch-update layout properties.
Since the layout pass scheduled is asynchronous, the rect
and size values may not be available immediately after
finishLayout
is called.
To be notified when the layout pass completes, add a listener for the postlayout event.
Fires a synthesized event to any registered listeners.
Name of the event.
A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.
Gets the value of the backgroundColor property.
Overrides: Titanium.UI.View.getBackgroundColor
Gets the value of the height property.
deprecated since 3.4.2
This property is deprecated. Set the height on the contentView property instead.
Overrides: Titanium.UI.View.getHeight
Gets the value of the title property.
deprecated since 3.4.2
This property is no longer supported.
Returns the matching view of a given view ID.
The ID of the view that should be returned. Use the id
property in your views to
enable it for indexing in this method.
Gets the value of the width property.
deprecated since 3.4.2
This property is deprecated. Set the width on the contentView property instead.
Overrides: Titanium.UI.View.getWidth
Hides the popover.
Display properties to use when hiding the popover.
Overrides: Titanium.UI.View.hide
Inserts a view at the specified position in the children array.
Useful if the layout
property is set to horizontal
or vertical
.
Pass an object with the following key-value pairs:
view
(Titanium.UI.View): View to insertposition
(Number): Position in the children array to
insert the view. If omitted, inserts the view to the end of the array.Removes a child from the popover.
This method has been removed since 3.4.2
Use the <Titanium.UI.iPad.Popover.contentView> property to modify the content of the popover.
View to remove from this view's hierarchy.
Overrides: Titanium.UI.View.remove
Removes the specified callback as an event listener for the named event.
Multiple listeners can be registered for the same event, so the
callback
parameter is used to determine which listener to remove.
When adding a listener, you must save a reference to the callback function in order to remove the listener later:
var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);
To remove the listener, pass in a reference to the callback function:
window.removeEventListener('click', listener);
Name of the event.
Callback function to remove. Must be the same function passed to addEventListener
.
Replaces a view at the specified position in the children array.
Useful if the layout
property is set to horizontal
or vertical
.
Pass an object with the following key-value pairs:
view
(Titanium.UI.View): View to insertposition
(Number): Position in the children array of
the view elment to replace.Sets the value of the arrowDirection property.
New value for the property.
Sets the value of the backgroundColor property.
New value for the property.
Overrides: Titanium.UI.View.setBackgroundColor
Sets the value of the backgroundDisabledColor property.
New value for the property.
Sets the value of the backgroundDisabledImage property.
New value for the property.
Sets the value of the backgroundFocusedColor property.
New value for the property.
Sets the value of the backgroundFocusedImage property.
New value for the property.
Sets the value of the backgroundSelectedColor property.
New value for the property.
Sets the value of the backgroundSelectedImage property.
New value for the property.
Sets the value of the bubbleParent property.
New value for the property.
Sets the value of the contentView property.
New value for the property.
Sets the value of the elevation property.
New value for the property.
Sets the value of the focusable property.
New value for the property.
Sets the value of the height property.
deprecated since 3.4.2
This property is deprecated. Set the height on the contentView property instead.
New value for the property.
Overrides: Titanium.UI.View.setHeight
Sets the value of the hiddenBehavior property.
New value for the property.
Sets the value of the keepScreenOn property.
New value for the property.
Sets the value of the lifecycleContainer property.
New value for the property.
Sets the value of the overrideCurrentAnimation property.
New value for the property.
Sets the value of the passthroughViews property.
New value for the property.
Sets the value of the previewContext property.
New value for the property.
Sets the value of the rotation property.
New value for the property.
Sets the value of the rotationX property.
New value for the property.
Sets the value of the rotationY property.
New value for the property.
Sets the value of the scaleX property.
New value for the property.
Sets the value of the scaleY property.
New value for the property.
Sets the value of the softKeyboardOnFocus property.
New value for the property.
Sets the value of the title property.
deprecated since 3.4.2
This property is no longer supported.
New value for the property.
Sets the value of the touchFeedback property.
New value for the property.
Sets the value of the touchFeedbackColor property.
New value for the property.
Sets the value of the transitionName property.
New value for the property.
Sets the value of the translationX property.
New value for the property.
Sets the value of the translationY property.
New value for the property.
Sets the value of the translationZ property.
New value for the property.
Sets the value of the width property.
deprecated since 3.4.2
This property is deprecated. Set the width on the contentView property instead.
New value for the property.
Overrides: Titanium.UI.View.setWidth
Displays the popover.
Display properties to use when displaying the popover.
Overrides: Titanium.UI.View.show
Starts a batch update of this view's layout properties.
deprecated since 3.0.0
Use the <Titanium.Proxy.applyProperties> method to batch-update layout properties.
To prevent a layout pass each time a property is modified, call startLayout
before
changing any properties that may change this view's layout. This initiates a batch update
mode where layout changes are deferred.
Call finishLayout to end batch update mode and trigger a layout pass. For example:
view.startLayout();
view.top = 50;
view.left = 50;
view.finishLayout();
Note that any property changes made during the batch update may be deferred until
finishLayout
is called. This may vary somewhat by platform. For example, changing the
text of a label may trigger a layout pass. In iOS, updating the label text is
deferred.
See also: updateLayout, finishLayout, postlayout event.
Performs a batch update of all supplied layout properties and schedules a layout pass after they have been updated.
deprecated since 3.0.0
Use the <Titanium.Proxy.applyProperties> method to batch-update layout properties.
This is another way to perform a batch update. The updateLayout
method is called with a
dictionary of layout properties to perform the batch update. For example:
view.updateLayout({top:50, left:50});
This is equivalent to the following:
view.startLayout();
view.top = 50;
view.left = 50;
view.finishLayout();
See also: startLayout, finishLayout, postlayout event.
Layout properties to be updated.
Fired when the view element gains focus.
This event only fires when using the trackball to navigate.
Source object that fired the event.
Name of the event fired.
True if the event will try to bubble up if possible.
Set to true to stop the event from bubbling.
Fired when the popover is hidden.
Source object that fired the event.
Name of the event fired.
True if the event will try to bubble up if possible.
Set to true to stop the event from bubbling.
Fired when a hardware key is pressed in the view.
A keypressed event is generated by pressing a hardware key. On Android, this event can only be fired when the property focusable is set to true. On iOS the event is generated only when using Ti.UI.TextArea, Ti.UI.TextField and Ti.UI.SearchBar.
The code for the physical key that was pressed. For more details, see KeyEvent. This API is experimental and subject to change.
Source object that fired the event.
Name of the event fired.
True if the event will try to bubble up if possible.
Set to true to stop the event from bubbling.
Fired when the device detects a long click.
A long click is generated by touching and holding on the touchscreen or holding down the trackball button.
The event occurs before the finger/button is lifted.
A longpress
and a longclick
can occur together.
As the trackball can fire this event, it is not intended to return the x
and y
coordinates of the touch, even when it is generated by the touchscreen.
A longclick
blocks a click
, meaning that a click
event will not fire when a
longclick
listener exists.
Source object that fired the event.
Name of the event fired.
True if the event will try to bubble up if possible.
Set to true to stop the event from bubbling.