flexlib :: library Documentation | All Packages | All Classes | Index | Frames No Frames |
ScrollableMenu

Package | flexlib.controls
Class | public class ScrollableMenu
Inheritance | ScrollableMenu mx.controls.Menu
Subclasses | ScrollableArrowMenu

An extension of mx.controls.Menu that allows the control to scroll vertically. <p>Overrides a few methods and properties so we can re-enable scrolling. The Menu control in the Flex framework intentionally disables vertical scrolling. This class simply undoes alot of that. We reinstitute normal <codeph>verticalScrollPolicy</codeph> functionality.</p>

Default MXML Property `dataProvider`

See also

mx.controls.Menu

Public Properties

| Property | Defined By
--- | --- | ---
|  | dataProvider : Object [override] [write-only] | ScrollableMenu
|  | hideOnActivity : Boolean = true | ScrollableMenu
|  | rowCount : int [override] [write-only] | ScrollableMenu
|  | verticalScrollPolicy : String [override] Override the verticalScrollPolicy so we can re-instate scrolling functionality. | ScrollableMenu

Public Methods

| Method | Defined By
--- | --- | ---
|  | ScrollableMenu() Constructor | ScrollableMenu
|  | createMenu(parent:DisplayObjectContainer, mdp:Object, showRoot:Boolean = true):ScrollableMenu [static] We have to override the static function createMenu so that we create a ScrollableMenu instead of a normal Menu. | ScrollableMenu
|  | hide():void [override] | ScrollableMenu
|  | move(x:Number, y:Number):void [override] | ScrollableMenu
|  | show(xShow:Object = null, yShow:Object = null):void [override] | ScrollableMenu

Protected Methods

| Method | Defined By
--- | --- | ---
|  | clearMenu(row:IMenuItemRenderer):void Clear the menu reference from the menu item renderer | ScrollableMenu
|  | configureScrollBars():void [override] Overridden to reinstate proper scrolling functionality. | ScrollableMenu
|  | createSubMenu():Menu | ScrollableMenu
|  | measure():void [override] We overide the measure() method because we need to check if the menu is going off the stage. | ScrollableMenu
|  | mouseUpHandler(event:MouseEvent):void [override] | ScrollableMenu
|  | onScroll(event:ScrollEvent):void Callback function called when the menu scroll bar is scrolled | ScrollableMenu
|  | updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void [override] | ScrollableMenu

Property Detail

dataProvider | property

`dataProvider:Object` [write-only] [override]

Implementation
`public function set dataProvider(value:Object):void`

hideOnActivity | property |

`public var hideOnActivity:Boolean = true`

rowCount | property |

`rowCount:int` [write-only] [override]

Implementation
`public function set rowCount(value:int):void`

verticalScrollPolicy | property |

`verticalScrollPolicy:String`[override]

Override the verticalScrollPolicy so we can re-instate scrolling functionality. <p>The mx.controls.Menu class overrides setting and getting the verticalScrollPolicy Basically setting the verticalScrollPolicy did nothing, and getting it always returned ScrollPolicy.OFF. So that's not going to work if we want the menu to scroll. Here we reinstate the verticalScrollPolicy setter, and keep a local copy of the value in a private variable _verticalScrollPolicy.</p>

Implementation
`public function get verticalScrollPolicy():String`
`public function set verticalScrollPolicy(value:String):void`
Constructor Detail

ScrollableMenu | () | Constructor

`public function ScrollableMenu()`

Constructor

Method Detail

clearMenu | () | method

`protected function clearMenu(row:IMenuItemRenderer):void`

Clear the menu reference from the menu item renderer

Parameters

| `row:IMenuItemRenderer` — The menu item renderer

configureScrollBars | () | method |

`override protected function configureScrollBars():void`

Overridden to reinstate proper scrolling functionality. <p>The Menu class overrode configureScrollBars() and made the function do nothing. That means the scrollbars don't know how to draw themselves, so here we reinstate configureScrollBars. This is basically a copy of the same method from the mx.controls.List class. It would have been nice if we could have called this method from down in a subclass of Menu, but AS doesn't let us do something like super.super, so instead we have to recreate the class here.</p>

createMenu | () | method |

`public static function createMenu(parent:DisplayObjectContainer, mdp:Object, showRoot:Boolean = true):ScrollableMenu`

We have to override the static function createMenu so that we create a ScrollableMenu instead of a normal Menu.

Parameters

| `parent:DisplayObjectContainer`
| `mdp:Object`
| `showRoot:Boolean` (default = `true`)``

Returns

| `ScrollableMenu`

createSubMenu | () | method |

`protected function createSubMenu():Menu`

Returns

| `Menu`

hide | () | method |

`override public function hide():void`

measure | () | method |

`override protected function measure():void`

We overide the <codeph>measure()</codeph> method because we need to check if the menu is going off the stage. If it's going to be too high, then we make it smaller to keep it from going off. I also stuck in a buffer of 10 pixels from the bottom of the stage. We also check if we're showing the vertical scrollbar, and if so we adjust the width to account for that.

mouseUpHandler | () | method |

`override protected function mouseUpHandler(event:MouseEvent):void`

Parameters

| `event:MouseEvent`

move | () | method |

`override public function move(x:Number, y:Number):void`

Parameters

| `x:Number`
| `y:Number`

onScroll | () | method |

`protected function onScroll(event:ScrollEvent):void`

Callback function called when the menu scroll bar is scrolled

Parameters

| `event:ScrollEvent` — The scroll event

show | () | method |

`override public function show(xShow:Object = null, yShow:Object = null):void`

Parameters

| `xShow:Object` (default = `null`)``
| `yShow:Object` (default = `null`)``

updateDisplayList | () | method |

`override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void`

Parameters

| `unscaledWidth:Number`
| `unscaledHeight:Number`

Mercredi Juillet 6 2011, 09:45 PM +02:00