# 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:
# 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
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
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
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
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
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
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
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 |
Returns
- Type
- void
# isVisible
Indicates whether the menu popup is currently visible.
Returns
- Type
- void
# removeEventListener
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 |
Returns
- Type
- void
# show
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
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. |