spark.layouts

# ViewMenuLayout - AS3 Flex

Package | spark.layouts
Class | public class ViewMenuLayout
Inheritance | ViewMenuLayout LayoutBase OnDemandEventDispatcher Object

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | AIR 2.5

The ViewMenuLayout class defines the layout of the ViewMenu container. The menu can have multiple rows depending on the number of menu items.

The `requestedMaxColumnCount` property defines the maximum number of menu items in a row. By default, the property is set to three.

The ViewMenuLayout class define the layout as follows:

- If you define three or fewer menu items, where the `requestedMaxColumnCount` property contains the default value of three, the menu items are displayed in a single row. Each menu item has the same size.

  If you define four or more menu items, meaning more menu items than specified by the `requestedMaxColumnCount` property, the ViewMenu container creates multiple rows.

- If the number of menu items is evenly divisible by the `requestedMaxColumnCount` property, each row contains the same number of menu items. Each menu item is the same size.

  For example the `requestedMaxColumnCount` property is set to the default value of three and you define six menu items. The menu displays two rows, each containing three menu items.

- If the number of menu items is not evenly divisible by the `requestedMaxColumnCount` property, rows can contain a different number of menu items. The size of the menu items depends on the number of menu items in the row.

  For example the `requestedMaxColumnCount` property is set to the default value of three and you define eight menu items. The menu displays three rows. The first row contains two menu items. The second and third rows each contains three items.

You can create your own custom layout for the menu by creating your own layout class. By default, the spark.skins.mobile.ViewMenuSkin class defines the skin for the ViewMenu container. To apply a customized ViewMenuLayout class to the ViewMenu container, define a new skin class for the ViewMenu container.

The ViewMenuSkin class includes a definition for a Group container named `contentGroup`, as shown below:

        <s:Group id="contentGroup" left="0" right="0" top="3" bottom="2"
            minWidth="0" minHeight="0">
            <s:layout>
                <s:ViewMenuLayout horizontalGap="2" verticalGap="2" id="contentGroupLayout"
                    requestedMaxColumnCount="3" requestedMaxColumnCount.landscapeGroup="6"/>
            </s:layout>
        </s:Group>

To apply your customized ViewMenuLayout class, your skin class should define a container named `contentGroup`. That container uses the `layout` property to specify your customized layout class.

MXML Syntax Show MXML Syntax
Hide MXML Syntax

The `<s:ViewMenuLayout>` tag inherits all of the tag attributes of its superclass and adds the following tag attributes:

      <s:ViewMenuLayout
        Properties
        horizontalGap="2"
        requestedMaxColumnCount="3"
        verticalGap="2"
      />

More examples

Set the layout of a ViewMenu container

Learn more

Define menus in a mobile application

Related API Elements

spark.components.ViewMenu
spark.components.ViewMenuItem
spark.skins.mobile.ViewMenuSkin

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | clipAndEnableScrolling : Boolean If true, specifies to clip the children to the boundaries of the viewport. | LayoutBase
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | dropIndicator : DisplayObject The DisplayObject that this layout uses for the drop indicator during a drag-and-drop operation. | LayoutBase
|  | horizontalGap : Number The horizontal space between columns, in pixels. | ViewMenuLayout
|  | horizontalScrollPosition : Number The x coordinate of the origin of the viewport in the component's coordinate system, where the default value is (0,0) corresponding to the upper-left corner of the component. | LayoutBase
|  | requestedMaxColumnCount : int The maximum number of columns to display in a row. | ViewMenuLayout
|  | target : GroupBase The GroupBase container whose elements are measured, sized and positioned by this layout. | LayoutBase
|  | typicalLayoutElement : ILayoutElement Used by layouts when fixed row/column sizes are requested but a specific size isn't specified. | LayoutBase
|  | useVirtualLayout : Boolean A container can hold any number of children. | LayoutBase
|  | verticalGap : Number The vertical space between rows, in pixels. | ViewMenuLayout
|  | verticalScrollPosition : Number The y coordinate of the origin of the viewport in the component's coordinate system, where the default value is (0,0) corresponding to the upper-left corner of the component. | LayoutBase

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | ViewMenuLayout() Constructor. | ViewMenuLayout
|  | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event. | OnDemandEventDispatcher
|  | calculateDropLocation(dragEvent:DragEvent):DropLocation Calculates the drop location in the data provider of the drop target for the specified dragEvent. | LayoutBase
|  | clearVirtualLayoutCache():void When useVirtualLayout is true, this method can be used by the layout target to clear cached layout information when the target changes. | LayoutBase
|  | dispatchEvent(event:Event):Boolean Dispatches an event into the event flow. | OnDemandEventDispatcher
|  | elementAdded(index:int):void Called by the target after a layout element has been added and before the target's size and display list are validated. | LayoutBase
|  | elementRemoved(index:int):void This method must is called by the target after a layout element has been removed and before the target's size and display list are validated. | LayoutBase
|  | getElementBounds(index:int):Rectangle Returns the specified element's layout bounds as a Rectangle or null if the index is invalid, the corresponding element is null, includeInLayout=false, or if this layout's target property is null. | LayoutBase
|  | getHorizontalScrollPositionDelta(navigationUnit:uint):Number Returns the change to the horizontal scroll position to handle different scrolling options. | LayoutBase
|  | getNavigationDestinationIndex(currentIndex:int, navigationUnit:uint, arrowKeysWrapFocus:Boolean):int Delegation method that determines which item to navigate to based on the current item in focus and user input in terms of NavigationUnit. | LayoutBase
|  | getScrollPositionDeltaToElement(index:int):Point Computes the verticalScrollPosition and horizontalScrollPosition deltas needed to scroll the element at the specified index into view. | LayoutBase
|  | getVerticalScrollPositionDelta(navigationUnit:uint):Number Returns the change to the vertical scroll position to handle different scrolling options. | LayoutBase
|  | hasEventListener(type:String):Boolean Checks whether the EventDispatcher object has any listeners registered for a specific type of event. | OnDemandEventDispatcher
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | hideDropIndicator():void Hides the previously shown drop indicator, created by the showDropIndicator() method, removes it from the display list and also stops the drag scrolling. | LayoutBase
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | measure():void Measures the target's default size based on its content, and optionally measures the target's default minimum size. | LayoutBase
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void Removes a listener from the EventDispatcher object. | OnDemandEventDispatcher
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | showDropIndicator(dropLocation:DropLocation):void Sizes, positions and parents the drop indicator based on the specified drop location. | LayoutBase
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | updateDisplayList(width:Number, height:Number):void Sizes and positions the target's elements. | LayoutBase
|  | updateScrollRect(w:Number, h:Number):void Called by the target at the end of its updateDisplayList to have the layout update its scrollRect. | LayoutBase
|  | valueOf():Object Returns the primitive value of the specified object. | Object
|  | willTrigger(type:String):Boolean Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type. | OnDemandEventDispatcher

Protected Methods
Hide Inherited Protected Methods
Show Inherited Protected Methods

| Method | Defined By
--- | --- | ---
|  | calculateDragScrollDelta(dropLocation:DropLocation, elapsedTime:Number):Point Calculates how much to scroll for the specified dropLocation during a drag and drop gesture. | LayoutBase
|  | calculateDropIndex(x:Number, y:Number):int Returns the index where a new item should be inserted if the user releases the mouse at the specified coordinates while completing a drag and drop gesture. | LayoutBase
|  | calculateDropIndicatorBounds(dropLocation:DropLocation):Rectangle Calculates the bounds for the drop indicator that provides visual feedback to the user of where the items will be inserted at the end of a drag and drop gesture. | LayoutBase
|  | getElementBoundsAboveScrollRect(scrollRect:Rectangle):Rectangle Returns the bounds of the first layout element that either spans or is above the scrollRect's top edge. | LayoutBase
|  | getElementBoundsBelowScrollRect(scrollRect:Rectangle):Rectangle Returns the bounds of the first layout element that either spans or is below the scrollRect's bottom edge. | LayoutBase
|  | getElementBoundsLeftOfScrollRect(scrollRect:Rectangle):Rectangle Returns the bounds of the first layout element that either spans or is to the left of the scrollRect's left edge. | LayoutBase
|  | getElementBoundsRightOfScrollRect(scrollRect:Rectangle):Rectangle Returns the bounds of the first layout element that either spans or is to the right of the scrollRect's right edge. | LayoutBase
|  | getScrollRect():Rectangle Returns the bounds of the target's scroll rectangle in layout coordinates. | LayoutBase
|  | scrollPositionChanged():void Called when the verticalScrollPosition or horizontalScrollPosition properties change. | LayoutBase

Property Detail

### horizontalGap

property

`horizontalGap:Number`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | AIR 2.5

The horizontal space between columns, in pixels.

The default value is `2.`

This property can be used as the source for data binding. When this property is modified, it dispatches the `propertyChange` event.

Implementation
`public function get horizontalGap():Number`
`public function set horizontalGap(value:Number):void`

Related API Elements

verticalGap

### requestedMaxColumnCount

property

`requestedMaxColumnCount:int`

Language Version: | ActionScript 3.0

Product Version: | Flex 4

Runtime Versions: | AIR 1.5

The maximum number of columns to display in a row.

The default value is `3.`

Implementation
`public function get requestedMaxColumnCount():int`
`public function set requestedMaxColumnCount(value:int):void`

### verticalGap

property

`verticalGap:Number`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | AIR 2.5

The vertical space between rows, in pixels.

The default value is `2.`

This property can be used as the source for data binding. When this property is modified, it dispatches the `propertyChange` event.

Implementation
`public function get verticalGap():Number`
`public function set verticalGap(value:Number):void`

Related API Elements

horizontalGap
Constructor Detail

### ViewMenuLayout

()
Constructor

`public function ViewMenuLayout()`

Language Version: | ActionScript 3.0

Product Version: | Flex 4.5

Runtime Versions: | AIR 2.5

Constructor.

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00