# 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:

Availability
5.2.0
9.2.0

# 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();

# Properties

# apiName READONLY

Availability
5.2.0
9.2.0
apiName :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, Titanium.UI.Button returns Ti.UI.Button.


# bubbleParent

Availability
5.2.0
9.2.0
bubbleParent :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.

Default: true


# items

Availability
5.2.0
9.2.0
items :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.

# Methods

# addEventListener

Availability
5.2.0
9.2.0
addEventListener(name, callback) void

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

Parameters

Name Type Description
name String

Name of the event.

callback Callback<Titanium.Event>

Callback function to invoke when the event is fired.

Returns

Type
void

# applyProperties

Availability
5.2.0
9.2.0
applyProperties(props) void

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

Name Type Description
props Dictionary

A dictionary of properties to apply.

Returns

Type
void

# fireEvent

Availability
5.2.0
9.2.0
fireEvent(name[, event]) void

Fires a synthesized event to any registered listeners.

Parameters

Name Type Description
name String

Name of the event.

event Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Returns

Type
void

# hide

Availability
5.2.0
9.2.0
hide([options]) void

Hides the menu popup.

Parameters

Name Type Description
options AnimatedOptions

Includes 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)

Returns

Type
void

# isVisible

Availability
5.2.0
9.2.0
isVisible() void

Indicates whether the menu popup is currently visible.

Returns

Type
void

# removeEventListener

Availability
5.2.0
9.2.0
removeEventListener(name, callback) void

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

Name Type Description
name String

Name of the event.

callback Callback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

Returns

Type
void

# show

Availability
5.2.0
9.2.0
show(options) void

Shows the menu popup.

Parameters

Name Type Description
options MenuPopupShowParams

Includes options how the menu popup should be shown. Note that the default is to be animated.

Returns

Type
void

# Events

# click

Availability
5.2.0
9.2.0

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.

Properties

Name Type Description
index Number

The index of the clicked item.

title String

The title of the clicked item.

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.