Skip to content

Titanium.UI.iOS.MenuPopup

A menu popup provides the ability to create custom tooltip options using the items property covering the native UIMenuController class.

See also:

Extends: Titanium.Proxy · Since: 5.2.0, 5.2.0, 9.2.0 · Platforms: iphone, ipad, macos

Properties #

apiName#

extended

Type: String

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.

bubbleParent#

extended

Type: Boolean

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.

items#

Type: Array<String>

The items of the menu popup.

The items will be shown as soon in the menu popup when the show method is called.
To hide them again, use the hide method in conjunction.

lifecycleContainer#

extended

Type: Titanium.UI.Window, Titanium.UI.TabGroup

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.

Methods #

addEventListener #

extended

Adds the specified callback as an event listener for the named event.

Parameters:
NameTypeSummaryOptional
nameStringName of the event.No
callbackCallback<Titanium.Event>Callback function to invoke when the event is fired.No

applyProperties #

extended

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.

Parameters:
NameTypeSummaryOptional
propsDictionaryA dictionary of properties to apply.No

fireEvent #

extended

Fires a synthesized event to any registered listeners.

Parameters:
NameTypeSummaryOptional
nameStringName of the event.No
eventDictionaryA dictionary of keys and values to add to the Titanium.Event object sent to the listeners.Yes

hide #

Hides the menu popup.

Parameters:
NameTypeSummaryOptional
optionsAnimatedOptionsIncludes options how the menu popup should be hidden. Introduced in SDK 5.2.0.

Note that the default here is equivalent to passing in { animated: true } (while typically the default for <AnimatedOptions> is false)
Yes

isVisible #

Indicates whether the menu popup is currently visible.

removeEventListener #

extended

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);
Parameters:
NameTypeSummaryOptional
nameStringName of the event.No
callbackCallback<Titanium.Event>Callback function to remove. Must be the same function passed to addEventListener.No

show #

Shows the menu popup.

Parameters:
NameTypeSummaryOptional
optionsMenuPopupShowParamsIncludes options how the menu popup should be shown. Note that the default is to be animated.No

Events #

click #

Fired when the user clicks at one of the menu popup items.

This event provides the properties title and index which relate to the name and position
of the clicked item inside the items property.

Event Properties:
NameTypeSummary
indexNumberThe index of the clicked item.
titleStringThe title of the clicked item.

Examples #

Example using multiple `items` and a `click` event.

The example below creates a new menu popup and shows it when the user clicks on the button.

var win = Ti.UI.createWindow({
    backgroundColor: "#fff",
});

var button = Ti.UI.createButton({
    title: "Show options"
});

win.add(button);

var menu = Ti.UI.iOS.createMenuPopup({
    items: ["Option 1", "Option 2"]
});

menu.addEventListener("click", function(e) {
    alert(e);
});

button.addEventListener("click", function() {
    menu.show({
      view: button
    });
});

win.open();

Titanium SDK Documentation