Skip to content
Titanium SDK
Version12.6.2

You are reading 12.6.2. See this page in 13.4.1.

Titanium.UI.iOS.MenuPopup

proxyiPhoneiPadmacOSsince iPhone 5.2.0, iPad 5.2.0, macOS 9.2.0

Extends Titanium.Proxy

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

See also:

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 3

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

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 7

Inherited from Titanium.Proxy

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

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

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

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

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

Hides the menu popup.

Parameters
ParametersTypeDescription
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)

Indicates whether the menu popup is currently visible.

Inherited from Titanium.Proxy

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

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

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

4 fields
bubbles Boolean

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

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Shows the menu popup.

Parameters
ParametersTypeDescription
optionsMenuPopupShowParams

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

3 fields
animated? Boolean

Determines whether the menu popup should be opened or closed animated.

arrowDirection Number

Indicates the arrow direction of the menu popup.

view Titanium.UI.View

The view where the menu pop is shown at.

Events 1

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
Event propertiesTypeDescription
indexNumber

The index of the clicked item.

titleString

The title of the clicked item.