com.judah.controls
class dndList
mx.updatedcontrols.List
|
+--com.judah.controls.dndList
class dndList extends List
Drag and drop list class
Extended and enhanced list component based off the Macromedia List. It follows the same model as the Macromedia List and can follow the same examples. The dndList inherits all the public properties and methods of the classes it inherits including all the properties and methods of the MovieClip > UIObject class > UIComponent class > View > ScrollView > ScrollSelectList > SelectableRow > List component > List classes chain. To begin, study the List class documentation and properties and methods it inherits.
- Example:This example shows to different methods how to fill the list with data.
// load data into List function loadData() { // method 1 var arr:Array = new Array(); arr.push({label:"File 1",data:"file"}); arr.push({label:"File 1",data:"file"}); arr.push({label:"File 3",data:"file"}); theList.dataProvider = arr; // method 2 theList.removeAll(); theList.addItem({label:".. ",data:"folder"}); theList.addItem({label:"Folder 1",data:"folder"}); theList.addItem({label:"Folder 2",data:"folder"}); theList.addItem({label:"File 1",data:"file"}); theList.addItem({label:"File 2",data:"file"}); theList.addItem({label:"File 3",data:"file"}); } loadData()
Field Summary
Add Branch constant
Add Item constant
Position to paste new branch items.
public addItem_Event
Event generated when an item is added
Position to add new items
Enable drag and drop on empty rows
Class name of the component class
time in milliseconds to separate doubleclick from a delayed click
Reference to the ContextMenu
Copy Item constant
Copy icon shown when dragging
public copyItem_Event
Event generated when a item is copied
Cut Item constant
public cutItem_Event
Event generated when a item is cut
Default data in the items in the list
Default branch item to use when adding a new list item
public defaultIcon
Default icon to show in the list
Default item to use when adding a new list item
public delayedClick_Event
Event generated when a row is delayed clicked
Enables or disables drag and drop
The height in pixels of the gutter space inbetween list items
Enables all move operations to be copy operations
Do not insert a row on drop
public doubleClick_Event
Event generated when a row is double clicked
Reference to movieclip when dragging and dropping rows
Creates an exact duplicate of the row you are dragging.
Transparency amount of the highlight rectangle when dragging
Start dragging when you mouse moves outside of the row
Contains current or last position of dragged item
The default row style of the rows in the drag mc
Drop Event constant
Enable branch menu item
Enables or disables the list
Displays or hides the highlight rectangle when dragging. Deprecated
Displays or hides an item's icon when dragging
Displays or hides the item label while dragging. Deprecated
Draws a drag line over rows
Displays or hides the default generic drag icon when dragging
Determines if keypresses in the list find and select rows
Determines if an item can be renamed
Enable tooltip
Error message variable
Default list of labels in the list
Index of the last moved item
Indices of the last moved list items
Reference to the last item moved
Reference to an array of the last moved list items
Parent item of the last moved item
Parent list items of the last moved list items
Owner of the last moved item
Reference to array of the owners of the last moved list items
Absolute index of the row the mouse was last over
Relative index of the row the mouse was last over
public menu
Reference to the current ContextMenu.
Menu Event constant
Method Call constant
Number of pixels the mouse must move before we start dragging
Enables mutiple selection of rows
Item icon shown when dragging
public onDrop_Event
Event generated after a drag and drop
Paste After constant
Paste Before constant
Paste Into constant
public pasteItem_Event
Event generated after pasteItem method is called
Remove Item constant
public removeItem_Event
Event generated when an item is removed
Rename Item constant
Name of rename label to access when using a cellrenderer
public renameItem_Event
Event generated when a item is renamed
Indicates set of characters user may enter into the rename text field.
Reference to the root movieclip
Scroll drag speed in milliseconds
Shows debug information
Show tooltips on all rows
public singleClick_Event
Event generated when a row is single clicked
Context Menu Item Add Branch string. Deprecated
Context Menu Item Add Leaf string. Deprecated
Id of icon to show when copying an item
Context Menu Item Copy string. Deprecated
Context Menu Item Cut string. Deprecated
Id of generic icon. Deprecated
Id of icon when dragging is not permitted
Context Menu Item Paste After string. Deprecated
Context Menu Item Paste Before string. Deprecated
Context Menu Item Paste Into string. Deprecated
public strRemoveItem
Context Menu Item Remove string. Deprecated
public strRenameItem
Context Menu Item Rename string. Deprecated
The name of the ActionScript class
The fully qualified class name
Reference to the target item after drag and drop
Reference to array of datagrid items created on cut or copy events
Reference to array of items created from cut or copy events
Reference to array of items converted to tree nodes on cut or copy events
Parent item where list items were pasted into
Relative index in the parent item where list items were pasted into
Tooltip delayed response in milliseconds
Tooltip depth
Track debug messages in errorMsg variable
Current version number for this component
Displays or hides the list
Property Summary
Sets the X coordinate for the copy icon
Gets the X coordinate for the copy icon
Sets the Y coordinate for the copy icon
Gets the Y coordinate for the copy icon
getterEnables or disables the right-click context menu
Method Summary
public convertToGridItem (
theItem
)
Converts single list item into a datagrid item
public convertToNode (
theItem
)
Converts single list item into a tree node
public copyItem (
theItems, eventSource
)
A function to copy list items from the list
public cutItem (
theItems, eventSource, eventType
)
A function to cut items from the list
public drawSeparator (
objPoint, row, dragOverPos, bCanDrop
)
Draws separator line when dragging
public getIsBranch (
item
)
Method to determine if the item is a branch
public getIsOpen (
theItem
)
Method to check if item is open.
public getItemIcon (
theItem, subIcon
)
Gets the icon id of the item
public getItemIndex (
theItem
)
Method to get index of item in list
public getItemLabel (
theItem, subLabel
)
Gets the label of the item
public getRoot (
mc
)
find root movieclip
public hideToolTip (
)
Method to hide tooltip
public iconFunction (
item
)
Method to dynamically set the icon of the row
public labelFunction (
item
)
Method to manually set the text of the row label
public modifyDragMC (
drag_mc
)
Modifies the drag movieclip before dragging
public onContextMenuSelect (
)
User customizable function for manipulating the context menu
public pasteItem (
theSourceItem, theTargetItem, pastePosition, moveItem, eventSource, eventConstant
)
Method to insert or move list items
public permitContextMenu (
theItem, theAction, theMenuItem, theContextMenu
)
A user defined function to display context menu items
public permitDropFunction (
theItem, theTargetItem, theAction
)
A user defined function to allow or prevent drop
public permitRemove (
obj, menuItem, menuCaption, eventType
)
Lets the user show an alert before a cut or remove event
public permitRename (
theItem
)
A user defined function to allow rename on a item
public removeClipboardItems (
)
removes items from copy and paste clipboard
public renameFunction (
rowIndex, eventSource
)
Lets the user override the normal rename method
A method to call to set the item label
Shows renaming textfield over row
public showToolTip (
)
Method to display tooltip
public toolTipFunction (
row_mc
)
Method to modify tooltip movieclip directly after it has been created
Validates renamed item labels
Field Documentation
ADD_BRANCH
public var ADD_BRANCH: Number
Add Branch constant
Add Branch constant. This is used in copy and paste type operations throughout the dndList methods. Value is 6. Not used at this time.
- Usage:trace(myInstance.ADD_BRANCH);
- Example:The example pastes an item after the selectedItem and generates an onAddBranchItem event.
var newItem = {label:"New Added Item",data:"10"}; theList.pasteItem(newItem, theList.selectedItem, theList.PASTE_AFTER, false, theList.METHOD_CALL, theList.ADD_BRANCH);
ADD_ITEM
public var ADD_ITEM: Number
Add Item constant
Add Item constant. This is used in copy and paste type operations throughout the dndList methods. Value is 5. This is mostly for internal use.
- Usage:trace(myInstance.ADD_ITEM);
- Example:The example pastes an item after the selectedItem and generates an onAddItem event.
var newItem = {label:"New Added Item",data:"10"}; theList.pasteItem(newItem, theList.selectedItem, theList.PASTE_AFTER, false, theList.METHOD_CALL, theList.ADD_ITEM);
addBranchPastePosition
public var addBranchPastePosition: Number
Position to paste new branch items.
Number. Indicates position to add new branch items when calling "Add Branch Item" from the context menu. The choices are dndList.PASTE_INTO, dndList.PASTE_AFTER and dndList.PASTE_BEFORE. By default all added items are added after the selected item or at the end of the list if no item is selected. This property is not supported in this version of the list but may be used in future versions.
- Usage:myInstance.addBranchPastePosition = myInstance.PASTE_AFTER
- Example:This code causes added branch list items to be inserted after the target item.
theList.addBranchPastePosition = theList.PASTE_AFTER;
addItem_Event
public var addItem_Event
Event generated when an item is added
Event. Event generated when an item is added from the context menu. This event includes three properties. Target is a reference to the list, eventSource contains an internal constant for MENU_EVENT or METHOD_CALL and pastePosition contains the location in the target item where the paste occured (passing the constants PASTE_INTO, PASTE_BEFORE, PASTE_AFTER). You can also listen for an onAddItem event.
- Example:The example below adds a listener to the addItem event.
// include delegation class import mx.utils.Delegate; // Add an addItem event function function addItemEvent(evt) { trace("An item has been added to the list!"); // reference to the list var theList = evt.target; // references to all the items involved trace("The added item or parent item="+theList.selectedItem); trace("The target item="+theList.targetItem); trace("pastePosition="+evt.pastePosition); trace("thePasteToPosition="+theList.thePasteToPosition); } // we add a function that "listens" for the add event. When a addItem event is generated this function is called. theList.addEventListener("addItem", Delegate.create(this, addItemEvent));
addItemPastePosition
public var addItemPastePosition: Number
Position to add new items
Number. Indicates position to add new items when calling "Add Item" from the context menu. The choices are dndList.PASTE_INTO, dndList.PASTE_AFTER and dndList.PASTE_BEFORE. By default all added items are added after the selected item or at the end of the list if no item is selected.
- Usage:myInstance.addItemPastePosition = myInstance.PASTE_AFTER;
- Example:This code causes added list items to be inserted before the selected item.
theList.addItemPastePosition = theList.PASTE_BEFORE;
canDropOnEmptyRows
public var canDropOnEmptyRows: Boolean
Enable drag and drop on empty rows
Boolean. Enables drag and drop onto empty rows. Empty rows are the rows that appear beneath the last occupied item in the list. The default value of canDropOnEmptyRows is true. This property can be set through Component panel by changing "Can Drop on Empty Rows" parameter value.
- Usage:myInstance.canDropOnEmptyRows = true;
- Example:The example below enables drag and drop on empty rows.
theList.canDropOnEmptyRows = true;
className
public var className: String
Class name of the component class
The name of the component class. This does not include the package name and has no corresponding setting in the Flash development environment. You can use the value of this variable when setting style properties.
clickThreshold
public var clickThreshold: Number
time in milliseconds to separate doubleclick from a delayed click
cm
public var cm: ContextMenu
Reference to the ContextMenu
ContextMenu; Reference to ContextMenu. The ContextMenu class is documented in the Help Panel. You can change the context menu items easily by following the examples in the Help Panel or by following the examples provided with the component.
The contextMenu has an additional method called, "find(caption:String)" that returns the item by matching the item's caption. Each customItem in the customItems array, the array of items that make up the context menu, have an additional "action" property that contains one of the dndTree contants, PASTE_INTO, PASTER_AFTER, etc. useful for internal dndTree methods.
When you create your own context menu items add the owner property. The owner should be a reference to the component. This allows the component to work inside nested movieclips.
This is also a duplicate of the menu property. You do not want to over write the menu property with your own menu because the menu will not work in nested movieclips in Flash Player 7 and 8. Instead add or remove items from the existing menu or if you would like to use a different menu add it to the contextMenu property. This will provide the necessary behaviors to work in nested movieclips and to handle selecting the node the mouse is over (which is not always the selected node). You can always revert back to the default contextMenu by setting contextMenu to the cm property.
To change the text of any of the existing menu items use the caption property. For example, theList.cm.customItems[0].caption = "new text".
The contextMenu has an additional method called, "find(caption:String)" that returns the item by matching the item's caption. Each customItem in the customItems array, the array of items that make up the context menu, have an additional "action" property that contains one of the dndTree contants, PASTE_INTO, PASTER_AFTER, etc. useful for internal dndTree methods.
When you create your own context menu items add the owner property. The owner should be a reference to the component. This allows the component to work inside nested movieclips.
This is also a duplicate of the menu property. You do not want to over write the menu property with your own menu because the menu will not work in nested movieclips in Flash Player 7 and 8. Instead add or remove items from the existing menu or if you would like to use a different menu add it to the contextMenu property. This will provide the necessary behaviors to work in nested movieclips and to handle selecting the node the mouse is over (which is not always the selected node). You can always revert back to the default contextMenu by setting contextMenu to the cm property.
To change the text of any of the existing menu items use the caption property. For example, theList.cm.customItems[0].caption = "new text".
- Usage:myInstance.cm;
- Example:This example shows how to add and remove menu items. See example files.
// get reference to the context menu menu items array - you may have to use the theList.menu property if you are using your own menu var menuItems = theList.cm.customItems; // create our new context menu items var newMenuItem = new ContextMenuItem("My Menu Item", doSomething, true); var newMenuItem2 = new ContextMenuItem("Inserted Item", doSomething, true); // set this when the component is in a nested movieclip newMenuItem.owner = theList; newMenuItem2.owner = theList; // add an item to the end of the list menuItems.push(newMenuItem); // remove two previous menu items menuItems.splice(5,2); // add a new item at the beginning of the menu stack menuItems.splice(0,0,newMenuItem2); // add a separator before item 1 menuItems[1].separatorBefore = true; // rename an existing menu item menuItems[1].caption = "Cut the item out"; // this function is called by our context menu items function doSomething(obj, menuItem) { // be aware of scope issues in this function trace("obj=" + obj) trace("you clicked " + menuItem.caption) } - See also:
COPY_ITEM
public var COPY_ITEM: Number
Copy Item constant
Copy Item constant. This is used in copy and paste type operations throughout the dndList methods. Value is 1. This is mostly for internal use.
- Usage:trace(myInstance.COPY_ITEM);
copyIcon
public var copyIcon: MovieClip
Copy icon shown when dragging
Copy icon shown when dragging. Use the strCopyIcon property to set this to icon different than the default icon.
- See also:
copyItem_Event
public var copyItem_Event
Event generated when a item is copied
Event. Event generated when a item is copied from the list. The copied items are placed into the property dndList.theCopyItems. When the items are cut, copied or removed they are copied into the dndComponent.theCopyItems, dndComponent.theCopyNodes and the dndComponent.theCopyGridItems arrays. If enableCrossDrag property is true then the cut, copied or removed items will be available to any dndComponent that also has their cross drag property enabled. This event includes two properties. Target is a reference to the List, eventSource contains an internal constant for the MENU_EVENT or METHOD_CALL.
- Example:The example below adds a listener to the copyItem event.
// include delegation class import mx.utils.Delegate; // Copy event function function copyItemEvent(evt) { trace("A item has been copied from the list!"); // reference to the list var theList = evt.target; // references to all the items involved trace("Copied items="+theList.theCopyItems); trace("Copied items="+theList.selectedItems); } // we add a function that "listens" for the copy event. When a copyItem event is generated this function is called. theList.addEventListener("copyItem", Delegate.create(this, copyItemEvent));
CUT_ITEM
public var CUT_ITEM: Number
Cut Item constant
Cut Item constant. This is used in copy and paste type operations throughout the dndList methods. Value is 0. This is mostly for internal use.
- Usage:trace(myInstance.CUT_ITEM);
cutItem_Event
public var cutItem_Event
Event generated when a item is cut
Event. Event generated when a item is cut from the list. The cut items are placed into the property dndList.theCopyItems. When the items are cut, copied or removed they are copied into the dndComponent.theCopyItems, dndComponent.theCopyNodes and the dndComponent.theCopyGridItems arrays. If enableCrossDrag property is true then the cut, copied or removed items will be available to any dndComponent that also has their cross drag property enabled. This event includes three properties. Target is a reference to the List, eventSource contains an internal constant for the MENU_EVENT or METHOD_CALL and removedIndices includes the indices of the removed items.
- Example:The example below adds a listener to the cutItem event.
// include delegation class import mx.utils.Delegate; // Cut event function function cutItemEvent(evt) { trace("A item has been cut from the list!"); // reference to the list var theList = evt.target; // references to all the items and components involved trace("Cut items="+theList.theCopyItems); trace("The parent or sibling item="+theList.selectedItem); } // we add a function that "listens" for the cut event. When a cutItem event is generated this function is called. theList.addEventListener("cutItem", Delegate.create(this, cutItemEvent));
data
public var data: Array
Default data in the items in the list
Default data in the items in the list. Use only in the Component Inspector. Use the dataProvider property in code.
- Usage:myInstance.dataProvider = [{label:"Item 1", data:10}, {label:"Item 2", data:20}, {label:"Item 3", data:30}];
- Example:The example below sets the labels and data of the list items.
theList.dataProvider = [{label:"Item 1", data:10}, {label:"Item 2", data:20}, {label:"Item 3", data:30}];
defaultBranchItem
public var defaultBranchItem: Object
Default branch item to use when adding a new list item
Object. Indicates the default branch item to use when adding a list item from the "Add Branch Item" context menu. You must enable enableBranchMenuItem to have "Add Branch Item" show up in the context menu.
- Usage:myInstance.defaultBranchItem = {label:"New Item", data:"100"};
- Example:This code sets the default branch item.
theList.defaultBranchItem = {label:"New Item", data:"100"};
defaultIcon
public var defaultIcon
Default icon to show in the list
Default icon to show in the list. The value of this would be the linkage identifier of a movieclip sized 16x16 or 18x16 in the library. If empty no icon is shown. You can show different icons dynamically by defining the iconFunction. See icon example. There are several built-in icons. These include dndLeafIcon, dndIcon, dndIcon2, dndBranchIcon, dndBranchIconOpened, dndNoDropIcon, dndNoDropIcon2, dndCopyIcon and dndGenericIcon. A step by step guide to creating icons is available on the website in the forums.
- Usage:myInstance.setStyle("defaultIcon","newIcon");
- Example:The example below sets the default icon to dndIcon2.
theList.setStyle("defaultIcon","dndIcon2"); - See also:
defaultItem
public var defaultItem: Object
Default item to use when adding a new list item
Object. Indicates the default item to use when adding a list item from the "Add Item" context menu.
- Usage:myInstance.defaultItem = {label:"New Item", data:"100"};
- Example:This code sets the default item.
theList.defaultItem = {label:"New Item", data:"100"};
delayedClick_Event
public var delayedClick_Event
Event generated when a row is delayed clicked
Event. Event generated when a row is delayed clicked. This event includes three properties. Target contains a reference to the List, rowIndex contains the index of the row within the visible rows and absRowIndex contains the absolute index of the row within all rows. You can use property to get a reference to item or row movieclip.
- Example:The example below adds a listener to the double click event.
// include delegation class import mx.utils.Delegate; // Delayed click event function function delayedClickEvent(evt) { trace("A row has been double clicked!"); // reference to the list var theList = evt.target; // references to all the items and components involved trace("absRowIndex="+evt.absRowIndex); trace("rowIndex="+evt.rowIndex); trace("delayedclicked item="+theList.selectedItem); } // we add a function that "listens" for the delayed click event. When a delayedClick event is generated this function gets called. theList.addEventListener("delayedClick", Delegate.create(this, delayedClickEvent));
dndEnabled
public var dndEnabled: Boolean
Enables or disables drag and drop
Enables drag and drop when set to true. When set to false drag and drop is disabled. Certain functions can still be performed with the context menu. This property is enabled by default. This property can be set through the Component panel by changing "Enable Drag and Drop" parameter value.
- Usage:myInstance.dndEnabled = true;
- Example:The example below enables drag and drop.
theList.dndEnabled = true;
dndGutter
public var dndGutter: Number
The height in pixels of the gutter space inbetween list items
Integer. Amount of space in pixels from the edge of a list item row that counts as the drop before or drop after zone. This is similar to the CSS padding attribute but is only used for drag and drop operations. The less this amount the more space there is to drop into a row. The default value of dndGutter is 5. So if a row height is 20 pixels then 5 pixels at the top and 5 pixels at the bottom of this row height is the gutter. By default this value makes no difference unless the row is determined to be a branch item (using the user defined getIsBranch method). If it is a branch item then this property comes into use. This property can be set through Component panel by changing "Gutter Space" parameter value.
- Usage:myInstance.dndGutter = 5;
- Example:The example below sets the gutter to 5 pixels.
theList.dndGutter = 5;
- See also:
dndReadOnly
public var dndReadOnly: Boolean
Enables all move operations to be copy operations
Boolean. Enables all move operations to be copy operations when dealing with external movieclips or components. This makes it convienent for your users to copy items out of a list without having to hold down the ctrl key (or open apple key in macintosh). The default value of dndReadOnly is false. This property can be set through Component panel by changing "Read Only" parameter value. Even with this option enabled you can move items inside the list around. To prevent this use permitDropFunction and permitContextMenu function. See permissions example.
- Usage:myInstance.dndReadOnly = true;
- Example:The example below enables the property.
theList.dndReadOnly = true;
- See also:
doNotInsertOnDrop
public var doNotInsertOnDrop: Boolean
Do not insert a row on drop
Boolean. Do not insert a row on drop. This allows you to drop on a row and generate a drop or onDrop event without actually inserting a row.
- Usage:myInstance.doNotInsertOnDrop = true;
- Example:The example below creates this behavior.
theList.doNotInsertOnDrop = true;
doubleClick_Event
public var doubleClick_Event
Event generated when a row is double clicked
Event. Event generated when a row is double clicked. This event includes three properties. Target contains a reference to the List, rowIndex contains the index of the row within the visible rows and absRowIndex contains the absolute index of the row within all rows. You can use property to get a reference to item or row movieclip.
- Example:The example below adds a listener to the double click event.
// include delegation class import mx.utils.Delegate; // Double click event function function doubleClickEvent(evt) { trace("A row has been double clicked!"); // reference to the list var theList = evt.target; // references to all the items and components involved trace("absRowIndex="+evt.absRowIndex); trace("rowIndex="+evt.rowIndex); trace("doubleclicked item="+theList.selectedItem); } // we add a function that "listens" for the double click event. When a doubleClick event is generated this function gets called. theList.addEventListener("doubleClick", Delegate.create(this, doubleClickEvent));
drag_mc
public var drag_mc: MovieClip
Reference to movieclip when dragging and dropping rows
Reference to movieclip when dragging and dropping rows. This movieclip only exists when a user starts dragging. It is the visual representation of the dragged contents. It contains many properties including gridItem, gridItems, node, nodes, item, items, dndReadOnly, multipleSelection, selectedIndex, selectedIndices, isDragging, moveAfterDropMode, owner, copyIcon, noDropIcon, nodeIcon0, bg_mc0, label_mc0 and origName. In addition to that each item in each of the arrays have the following properties:
item.bIsNodeBranch; item.bIsBranch; item.bIsNodeOpen; item.bIsOpen; item.owner; item.indices; item.itemIndex; item.readOnly; // self removing method item.removeMe();You can use the modifyDragMC function to modify the drag_mc before it is dragged.
- Usage:myInstance.drag_mc;
- Example:The example below adds a property to drag_mc.
theList.modifyDragMC = function (theDrag_mc) { theDrag_mc.myProp = "Bill"; trace(theDrag_mc.items.length); } - See also:
dragDuplicateRow
public var dragDuplicateRow: Boolean
Creates an exact duplicate of the row you are dragging.
Boolean. This feature creates an exact duplicate of the row you are dragging. This feature was created after many of the other drag features were already created and makes the other features obsolete. You can choose the style of the dragged duplicate row by setting the dragRowStyle. Using this style property you can drag a duplicate row in any of the row states, "normal", "selected" or hightlight". You should enable this property to have an exact copy of the row you are dragging and if you need to modify it then make modifications to the drag_mc using the modifyDragMC function. Enumerate drag_mc in the modifyDragMC function to see the properties. Reference the row_mc0 property of the drag_mc to modify it's properties.
- Usage:myInstance.dragDuplicateRow = true;
- Example:The example below disables the dragDuplicateRow property.
theList.dragDuplicateRow = false;
- See also:
dragHighlightAlpha
public var dragHighlightAlpha: Number
Transparency amount of the highlight rectangle when dragging
Number. Transparency amount of the highlight rectangle when dragging. The default value of dragHighlightAlpha is 50.
- Usage:myInstance.dragHighlightAlpha = 30;
- Example:The example below sets the transparency to 30 percent.
theList.dragHighlightAlpha = 30;
dragOnRollOut
public var dragOnRollOut: Boolean
Start dragging when you mouse moves outside of the row
Start dragging when you mouse moves outside of the row. The default behavior is to drag after moving four pixels from the row press location. When this option is enabled then you do not begin to drag until the mouse moves outside of the clicked row.
- Example:The example enables dragOnRollOut:
theList.dragOnRollOut = true;
- See also:
dragOverPos
public var dragOverPos: Number
Contains current or last position of dragged item
Contains current or last paste position of a dragged item. When dragging this property contains one of the constants dndList.PASTE_INTO, dndList.PASTE_AFTER or dndList.PASTE_BEFORE.
- Usage:myInstance.dragOverPos;
- Example:The example below returns the position where the mouse was dragged over.
trace(theList.dragOverPos);
dragRowStyle
public var dragRowStyle: String
The default row style of the rows in the drag mc
String. The default row style of the rows in the drag mc. Can be either "normal", "selected" or "highlight". The default style is "selected". You must have dragDuplicateRow set to true for this.
- Usage:myInstance.dragRowStyle = "normal";
- Example:The example below sets the dragRowStyle to "normal".
theDataGrid.dragRowStyle = "normal";
- See also:
DROP_EVENT
public var DROP_EVENT: Number
Drop Event constant
Drop Event constant. Used with drag and drop operations. Value is 20.
- Usage:trace(myInstance.DROP_EVENT);
- Example:Traces constant value.
trace(theList.DROP_EVENT);
enableBranchMenuItem
public var enableBranchMenuItem: Boolean
Enable branch menu item
Boolean. Enable branch menu item. When the list is created it will add "Add Branch" to the menu items.
- Usage:myInstance.enableBranchMenuItem = true;
- Example:The code below enables the branch menu item.
theList.enableBranchMenuItem = true;
- See also:
enabled
public var enabled: Boolean
Enables or disables the list
Enables the list when set to true. When set to false the list is disabled.
- Usage:myInstance.enabled = true;
- Example:The example below enables the list.
theList.enabled = true;
enableDragHighlight
public var enableDragHighlight: Boolean
Displays or hides the highlight rectangle when dragging. Deprecated
Boolean. Displays or hides the highlight rectangle when dragging. Deprecated. The dragDuplicateRow must be set to false for this to have an effect. This property is deprecated in favor enabling the dragDuplicateRow property and setting the dragRowStyle to "normal", "selected" or "highlight".
- Usage:myInstance.enableDragHighlight = true;
- Example:The example below enables the property.
theList.enableDragHighlight = true;
- See also:
enableDragIcon
public var enableDragIcon: Boolean
Displays or hides an item's icon when dragging
Boolean. Displays or hides an item's icon when dragging. The dragDuplicateRow must be set to false for this to have an effect. This property is deprecated in favor enabling the dragDuplicateRow property and modifying the drag_mc directly using the modifyDragMC function.
- Usage:myInstance.enableDragIcon = true;
- Example:The example below enables the property.
theList.enableDragIcon = true;
enableDragLabel
public var enableDragLabel: Boolean
Displays or hides the item label while dragging. Deprecated
Boolean. Displays or hides the item label while dragging. Deprecated. The dragDuplicateRow must be set to false for this to have an effect. This property is deprecated in favor enabling the dragDuplicateRow property and modifying the drag_mc directly using the modifyDragMC function.
- Usage:myInstance.enableDragLabel = true;
- Example:The example below shows the item label when dragging
theList.enableDragLabel = true;
- See also:
enableDragLine
public var enableDragLine: Boolean
Draws a drag line over rows
Boolean. Draws a drag line over rows as a visual guideline. As you drag over the List rows the drag separator will pause before, after or in the middle of the row. You can modify the look and feel of the drag line using the drawSeparator function.
- Usage:myInstance.drawDragLine = true;
- Example:The code below turns on the drag line.
theList.drawDragLine = true;
- See also:
enableGenericIcon
public var enableGenericIcon: Boolean
Displays or hides the default generic drag icon when dragging
Boolean. Displays or hides the default generic drag icon when dragging instead of the current item icon. The dragDuplicateRow must be set to false for this to have an effect. This property is deprecated in favor enabling the dragDuplicateRow property and modifying the drag_mc directly using the modifyDragMC function.
- Usage:myInstance.enableGenericIcon = true;
- Example:The example below enables the generic icon.
theList.enableGenericIcon = true;
enableKeySearch
public var enableKeySearch: Boolean
Determines if keypresses in the list find and select rows
Boolean. Determines if keypresses in the list find and select rows. If enabled then the user can type a key and the list will search for the row by the current key pressed. For example, if you have row with a label named "John" and you click the letter "J" then the row is selected. If multiple rows start with the letter "J" then the rows are selected in order. You can use the built in keyPressFunction to handle additional key presses.
- Usage:myInstance.enableKeySearch = true;
- Example:The code below enables key searching.
theList.enableKeySearch = true;
enableRenameItem
public var enableRenameItem: Boolean
Determines if an item can be renamed
Boolean. Determines if an item can be renamed from within the textfield that appears in the list. If enabled then the user can double click on an item and a rename textfield appears. You can also choose "Rename Item" from the context menu. The user can then type in new text for the item label. Esc cancels the edit. Enter or tab commits the edit. You can use the renameTextRestrict property and validateItemLabel for more control. If you define the labelFunction you must redefine the setItemLabel function. You can also disable renaming on double click events but continue to rename through the context menu using the renameOnDoubleClick property. See examples.
- Usage:myInstance.enableRenameItem = true;
- Example:The example below enables the rename feature.
theList.enableRenameItem = false;
- See also:
enableToolTip
public var enableToolTip: Boolean
Enable tooltip
Enable the tooltip. When this is enabled and the cell does not fit into the width of the component then a tooltip is show next to the mouse. You can set the time before the tooltip is shown by changing the toolTipDelay property. You can set the showToolTipsOnAllRows property to show tool tips on all rows regardless if they fit in the component or not. Note: The tooltip depth is set to 1000 on the root level by default. To set it higher or lower set the toolTipDepth. You can style the tooltip by using the toolTipFunction.
- See also:
errorMsg
public var errorMsg: String
Error message variable
String. Tracks debug messages variable when trackDebug is true. Trace this to see the event log. Deprecated. Use the support forums for help.
- Usage:myInstance.errorMsg;
- Example:The example below traces debug information in the errorMsg variable.
trace(theList.errorMsg);
labels
public var labels: Array
Default list of labels in the list
Default list of labels in the list. Use only in the Component Inspector. Use the dataProvider property in code.
- Usage:myInstance.dataProvider = [{label:"Item 1"}, {label:"Item 2"}, {label:"Item 3"}];
- Example:The example below sets the labels of the list items.
theList.dataProvider = [{label:"Item 1"}, {label:"Item 2"}, {label:"Item 3"}];
lastMovedIndex
public var lastMovedIndex: Number
Index of the last moved item
Boolean. Index of the last moved item in the list. This property is set after a successful add, drop or paste event.
- Usage:movedItemIndex = myInstance.lastMovedIndex;
- Example:The example returns the index of the last moved item.
movedItemIndex = theList.lastMovedIndex;
lastMovedIndices
public var lastMovedIndices: Array
Indices of the last moved list items
Array of indices of the last moved list items in the list. This property is set after a successful add, drop or paste event.
- Usage:movedItemIndex = myInstance.lastMovedIndices[0];
- Example:The example returns the index of the first item in the last moved list items array.
movedItemIndex = theList.lastMovedIndices[0];
lastMovedItem
public var lastMovedItem: Object
Reference to the last item moved
Boolean. Reference to the last item moved in the list. This property is set after a successful add, drop or paste event.
- Usage:movedItem = myInstance.lastMovedItem;
- Example:The example returns the last moved item.
movedItem = theList.lastMovedItem;
lastMovedItems
public var lastMovedItems: Array
Reference to an array of the last moved list items
Reference to an array of the last moved list items in the list. This property is set after a successful add, drop or paste event.
- Usage:movedItem = myInstance.lastMovedItems[0];
- Example:The example gets the total number of moved list items.
movedItemsLength = theList.lastMovedItems.length;
lastMovedParent
public var lastMovedParent: Object
Parent item of the last moved item
Boolean. Parent item of the last moved item. This property is set after a successful add, drop or paste event. This property is not supported in this version of the list but may be used in future versions.
- Usage:parentItem = myInstance.lastMovedParent;
- Example:The example returns the parent item of the last moved item.
parentItem = theList.lastMovedParent;
lastMovedParents
public var lastMovedParents: Array
Parent list items of the last moved list items
Array of list items. Parent list items of each of the last moved list items. This property is set after a successful add, drop or paste event. This property is not supported in this version of the list but may be used in future versions.
- Usage:parentItem = myInstance.lastMovedParents[0];
- Example:The example returns the parent item of the first item in the last moved list items array.
parentItem = theList.lastMovedParents[0];
lastMovedSource
public var lastMovedSource: Object
Owner of the last moved item
Object. Owner of the last moved item. This property is set after a successful add, drop or paste event.
- Usage:theItemSource = myInstance.lastMovedSource;
- Example:The example returns the owner of the last moved item.
theItemSource = theList.lastMovedSource;
lastMovedSources
public var lastMovedSources: Object
Reference to array of the owners of the last moved list items
Reference to array of the owners of the last moved list items. Typically this will be another dndList or a drag and drop component. This property is set after a successful add, drop or paste event.
- Usage:theItemSource = myInstance.lastMovedSources[0];
- Example:The example returns the owner of the first item in the last moved list items array.
theItemSource = theList.lastMovedSources[0];
lastOver
public var lastOver: Number
Absolute index of the row the mouse was last over
Number. Absolute index of the row the mouse was last over.
- Usage:myInstance.lastOver;
- Example:The example below traces the property.
trace(theList.lastOver);
lastOverIndex
public var lastOverIndex: Number
Relative index of the row the mouse was last over
Number. Relative index of the row the mouse was last over.
- Usage:myInstance.lastOverIndex;
- Example:The example below traces the property.
trace(theList.lastOverIndex);
menu
public var menu
Reference to the current ContextMenu.
ContextMenu; Reference to ContextMenu. Use the contextMenu property to set new context menu. Only use this property to modify the existing menu. See the help on the "cm" property.
- See also:
MENU_EVENT
public var MENU_EVENT: Number
Menu Event constant
Menu Event constant. Used with pasteItem method. Value is 21.
- Usage:trace(myInstance.MENU_EVENT);
- Example:Traces constant value.
trace(theList.MENU_EVENT);
METHOD_CALL
public var METHOD_CALL: Number
Method Call constant
Method Call constant. Used with pasteItem method. Value is 22.
- Usage:trace(myInstance.METHOD_CALL);
- Example:Traces constant value.
trace(theList.METHOD_CALL);
movementBeforeDrag
public var movementBeforeDrag: Number
Number of pixels the mouse must move before we start dragging
Number of pixels the mouse must move before we start dragging. The default behavior is to drag after moving four pixels from the row press location. The dragOnRollOut property must be false for this to work.
- Example:The example sets movementBeforeDrag to 8 pixels:
theList.movementBeforeDrag = 8;
multipleSelection
public var multipleSelection: Boolean
Enables mutiple selection of rows
Boolean. Enables mutiple rows to be selected and operated on. Use the CTRL and SHIFT keys to select multiple rows.
- Usage:myInstance.multipleSelection = true;
- Example:The example below enables multiple selection.
theList.multipleSelection = true;
nodeIcon
public var nodeIcon: MovieClip
Item icon shown when dragging
Item icon shown when dragging. The icon displayed is dynamically created from whatever icon is in the row at the time it is dragged. It can be turned off by setting the enableDragIcon to false.
- See also:
onDrop_Event
public var onDrop_Event
Event generated after a drag and drop
Event. Event generated after a drag and drop of items. This event includes three properties. Target contains a reference to the List, eventSource contains an internal constant for the DROP_EVENT and pastePosition contains the location in the target item where the paste occured (PASTE_INTO, PASTE_BEFORE, PASTE_AFTER). The onDrop event is to be used in favor of drop.
- Example:The example below adds a listener to the onDrop event.
// include delegation class import mx.utils.Delegate; // Drop Event function itemDrop(evt) { // reference to the list var theList = evt.target; // references to all the items and components involved trace("pastePosition="+evt.pastePosition); trace("targetItem="+evt.targetItem); trace("targetIndex="+evt.targetIndex); trace("thePasteToPosition="+theList.thePasteToPosition); trace("thePasteToParentItem="+theList.thePasteToParentItem); trace("lastMovedItem="+theList.lastMovedItem); trace("lastMovedIndex="+theList.lastMovedIndex); trace("lastMovedParent="+theList.lastMovedParent); trace("lastMovedSource="+theList.lastMovedSource); trace("lastMovedItems="+theList.lastMovedItems); trace("lastMovedIndices="+theList.lastMovedIndices); trace("lastMovedParents="+theList.lastMovedParents); trace("lastMovedSources="+theList.lastMovedSources); trace("targetItem="+theList.targetItem); } // we add a function that "listens" for the onDrop event. When an onDrop event is generated this function gets called. theList.addEventListener("onDrop", Delegate.create(this, itemDrop));
PASTE_AFTER
public var PASTE_AFTER: Number
Paste After constant
Paste After constant. This is used in copy and paste type operations throughout the dndList methods. Value is 4.
- Usage:trace(myInstance.PASTE_AFTER);
- Example:The example inserts a new item after the selectedItem.
var newItem = {label:"New Added Item",data:"10"}; theList.pasteItem(newItem, theList.selectedItem, theList.PASTE_AFTER);
PASTE_BEFORE
public var PASTE_BEFORE: Number
Paste Before constant
Paste Before constant. This is used in copy and paste type operations throughout the dndList methods. Value is 3.
- Usage:trace(myInstance.PASTE_BEFORE);
- Example:The example inserts a new item before the selectedItem.
var newItem = {label:"New Added Item",data:"10"}; theList.pasteItem(newItem, theList.selectedItem, theList.PASTE_BEFORE);
PASTE_INTO
public var PASTE_INTO: Number
Paste Into constant
Paste Into constant. This is used in copy and paste type operations throughout the dndList methods. Value is 2.
- Usage:trace(myInstance.PASTE_INTO);
- Example:The example inserts a new item into the selectedItem.
var newItem = {label:"New Added Item",data:"10"}; theList.pasteItem(newItem, theList.selectedItem, theList.PASTE_INTO);
pasteItem_Event
public var pasteItem_Event
Event generated after pasteItem method is called
Event. Event generated after pasteItem method is called. This event includes three properties. Target contains a reference to the List, eventSource contains an internal constant for METHOD_CALL and pastePosition contains the location in the target item where the paste occured (PASTE_INTO, PASTE_BEFORE, PASTE_AFTER). You can also listen for an onPasteItem event.
- Example:The example below adds a listener to the pasteItem event.
// include delegation class import mx.utils.Delegate; // Paste Item event function function pasteItemEvent(evt) { // reference to the list var theList = evt.target; // references to all the items and components involved trace("pastePosition="+evt.pastePosition); trace("thePasteToPosition="+theList.thePasteToPosition); trace("lastMovedItem="+theList.lastMovedItem); trace("lastMovedIndex="+theList.lastMovedIndex); trace("lastMovedSource="+theList.lastMovedSource); trace("lastMovedItems="+theList.lastMovedItems); trace("lastMovedIndices="+theList.lastMovedIndices); trace("lastMovedSources="+theList.lastMovedSources); trace("targetItem="+theList.targetItem); } // we add a function that "listens" for the paste event. When a pasteItem event is generated this function gets called. theList.addEventListener("pasteItem", Delegate.create(this, pasteItemEvent));
REMOVE_ITEM
public var REMOVE_ITEM: Number
Remove Item constant
Remove Item constant. This is used in copy and paste type operations throughout the dndList methods. Value is 7. This is mostly for internal use.
- Usage:trace(myInstance.REMOVE_ITEM);
- Example:The example cuts the selectedItem and we use REMOVE_ITEM to generate a onRemoveItem event.
theList.cutItem(theList.selectedItem, theList.REMOVE_ITEM);
removeItem_Event
public var removeItem_Event
Event generated when an item is removed
Event. Event generated when an item is removed from the list. The cut items are placed into the property dndList.theCopyItems. When the items are cut, copied or removed they are copied into the dndComponent.theCopyItems, dndComponent.theCopyNodes and the dndComponent.theCopyGridItems arrays. If enableCrossDrag property is true then the cut, copied or removed items will be available to any dndComponent that also has their cross drag property enabled. This event includes three properties. Target is a reference to the List, eventSource contains an internal constant for the MENU_EVENT or METHOD_CALL and removedIndices includes the indices of the removed items.
- Example:The example below adds a listener to the removeItem event.
// include delegation class import mx.utils.Delegate; // Remove Event function removeItem(evt) { // reference to the list var theList = evt.target; // references to all the items and components involved trace("Removed items="+theList.theCopyItems); } // we add a function that "listens" for the remove event. When a removeItem event is generated this function gets called. theList.addEventListener("removeItem", Delegate.create(this, removeItem));
RENAME_ITEM
public var RENAME_ITEM: Number
Rename Item constant
Rename Item constant. This is used in the rename operations throughout the dndList methods. Value is 8.
- Usage:trace(myInstance.RENAME_ITEM);
- Example:Traces constant value.
trace(theList.RENAME_ITEM);
renameField
public var renameField: String
Name of rename label to access when using a cellrenderer
String. Name of rename label to access when using a cellrenderer. If you create a label in your cellrenderer you should set this property to the name of the label.
- Usage:myInstance.renameField = "mylabel";
- Example:
theList.renameField = "theLabel";
renameItem_Event
public var renameItem_Event
Event generated when a item is renamed
Event. Event generated when a item is renamed. This event includes five properties. Target is a reference to the List, rowIndex is reference to the row index, row is a reference to the row, item is a reference to the item and originalText is a reference to the original text. See also validateItemLabel and renameTextRestrict.
- Example:The example below adds a listener to the renameItem event.
// include delegation class import mx.utils.Delegate; // renameItem event function function renameItem(evt) { trace("A item has been renamed"); // reference to the list var theList = evt.target; // references to all the items involved trace("The renamed item="+evt.item); trace("The rowIndex="+evt.rowIndex); trace("The row movieclip="+evt.row); trace("The original text="+evt.originalText); } // we add a function that "listens" for the renameItem event. When a renameItem event is generated this function is called. theList.addEventListener("renameItem", Delegate.create(this, renameItem)); - See also:
renameTextRestrict
public var renameTextRestrict: String
Indicates set of characters user may enter into the rename text field.
String. Indicates a set of characters user may enter into rename text field. See the Textfield.restrict property for more information. See also validateItemLabel
- Usage:myInstance.renameTextRestrict = "A-Za-z0-9 ";
- Example:The example limits the text to only allows letters, numbers and spaces.
theList.renameTextRestrict = "A-Za-z0-9 ";
- See also:
root_mc
public var root_mc: MovieClip
Reference to the root movieclip
Movieclip. Reference to the root movieclip. If you load in a swf you may need to set this property to the root movieclip.
- Usage:myInstance.root_mc = _root;
- Example:The example sets a reference to the the root movieclip.
theList.root_mc = _root;
scrollDragSpeed
public var scrollDragSpeed: Number
Scroll drag speed in milliseconds
Scroll drag speed in milliseconds. This is the setting you change to speed up or speed down when you drag up or drag down and the vertical position moves.
- Usage:myInstance.scrollDragSpeed = 100;
- Example:Sets the scroll speed to 100 milliseconds.
theList.scrollDragSpeed = 100;
showDebug
public var showDebug: Boolean
Shows debug information
Shows debug information when available in the trace console. Deprecated. Use the support forums for help.
- Usage:myInstance.showDebug = true;
- Example:The example below shows debug information.
theList.showDebug = true;
showToolTipsOnAllRows
public var showToolTipsOnAllRows: Boolean
Show tooltips on all rows
Show tooltips on all rows. By default tooltips are only shown on rows that do not fit inside the width of the list. Enabling this property causes tooltips to show up on all rows.
- Usage:myInstance.showToolTipsOnAllRows = true;
- Example:This example enables showToolTipsOnAllRows.
theList.showToolTipsOnAllRows = true;
- See also:
singleClick_Event
public var singleClick_Event
Event generated when a row is single clicked
Event. Event generated when a row is single clicked. This event includes three properties. Target contains a reference to the List, rowIndex contains the index of the row within the visible rows and absRowIndex contains the absolute index of the row within all rows. You can use property to get a reference to the item or row movieclip.
- Example:The example below adds a listener to the single click event.
// include delegation class import mx.utils.Delegate; // Double click event function function singleClickEvent(evt) { trace("A row has been single clicked!"); // reference to the list var theList = evt.target; // references to all the items and components involved trace("absRowIndex="+evt.absRowIndex); trace("rowIndex="+evt.rowIndex); trace("this item has been clicked="+theList.selectedItem); } // we add a function that "listens" for the single click event. When a singleClick event is generated this function gets called. theList.addEventListener("singleClick", Delegate.create(this, singleClickEvent));
strAddBranch
public var strAddBranch: String
Context Menu Item Add Branch string. Deprecated
The string of the add branch menu item. Deprecated. To change the text of any of the existing menu items use the contextMenu.customItems.caption property. Note: The Flash Player will not show the menu item if the caption is set to any of the reserved words, "cut, copy, paste".
- Usage:myInstance.cm.customItems[0].caption = "new text"
- Example:The example below changes the text of the first menu item.
theList.menu.customItems[0].caption = "new text";
strAddItem
public var strAddItem: String
Context Menu Item Add Leaf string. Deprecated
The string of the add item menu item. Deprecated. To change the text of any of the existing menu items use the contextMenu.customItems.caption property. Note: The Flash Player will not show the menu item if the caption is set to any of the reserved words, "cut, copy, paste".
- Usage:myInstance.cm.customItems[0].caption = "new text"
- Example:The example below changes the text of the first menu item.
theList.menu.customItems[0].caption = "new text";
strCopyIcon
public var strCopyIcon: String
Id of icon to show when copying an item
Id of icon to show when copying an item. The default value of strCopyIcon is "dndCopyIcon". Any other movieclip you use must exist in the library and have it's linkage identifier set. This property can be set through the Component panel by changing "Copy Icon" parameter value.
- Usage:myInstance.strCopyIcon = "myIconId";
- Example:The example below sets the copy icon to "myIcon".
theList.dndCopyIcon = "myIcon";
strCopyItem
public var strCopyItem: String
Context Menu Item Copy string. Deprecated
The string of the copy menu item. Deprecated. To change the text of any of the existing menu items use the contextMenu.customItems.caption property. Note: The Flash Player will not show the menu item if the caption is set to any of the reserved words, "cut, copy, paste".
- Usage:myInstance.cm.customItems[0].caption = "new text"
- Example:The example below changes the text of the first menu item.
theList.menu.customItems[0].caption = "new text";
strCutItem
public var strCutItem: String
Context Menu Item Cut string. Deprecated
The string of the cut menu item. Deprecated. To change the text of any of the existing menu items use the contextMenu.customItems.caption property. Note: The Flash Player will not show the menu item if the caption is set to any of the reserved words, "cut, copy, paste".
- Usage:myInstance.cm.customItems[0].caption = "new text"
- Example:The example below changes the text of the first menu item.
theList.menu.customItems[0].caption = "new text";
strGenericIcon
public var strGenericIcon: String
Id of generic icon. Deprecated
Id of generic icon. Deprecated. This is the icon to use when dragging in the alternate dragging mode. The default value of strGenericIcon is "dndGenericIcon". Any other movieclip you use must exist in the library or on the stage and have it's linkage identifier set. This property can be set through the Component panel by changing "Generic Drag Icon" parameter value.
- Usage:myInstance.strGenericIcon = "newValue";
- Example:The example below sets the generic icon to "myIcon".
theList.strGenericIcon = "myIcon";
- See also:
strNoDropIcon
public var strNoDropIcon: String
Id of icon when dragging is not permitted
Id of icon when dragging is not permitted. The default value of strNoDropIcon is "dndNoDropIcon". Any other movieclip you would use must exist in the library with it's linkage identify set. This property can be set through the Component panel by changing "No Drop Icon" parameter value. The dndList includes an additional built-in no drop allowed icon called "dndNoDropIcon2".
- Usage:myInstance.strNoDropIcon = "dndNoDropIcon2";
- Example:The example below sets the no drop icon to the alternative no drop icon.
theList.strNoDropIcon = "dndNoDropIcon2";
strPasteAfter
public var strPasteAfter: String
Context Menu Item Paste After string. Deprecated
The string of the paste after menu item. Deprecated. To change the text of any of the existing menu items use the contextMenu.customItems.caption property. Note: The Flash Player will not show the menu item if the caption is set to any of the reserved words, "cut, copy, paste".
- Usage:myInstance.cm.customItems[0].caption = "new text"
- Example:The example below changes the text of the first menu item.
theList.menu.customItems[0].caption = "new text";
strPasteBefore
public var strPasteBefore: String
Context Menu Item Paste Before string. Deprecated
The string of the paste before menu item. Deprecated. To change the text of any of the existing menu items use the contextMenu.customItems.caption property. Note: The Flash Player will not show the menu item if the caption is set to any of the reserved words, "cut, copy, paste".
- Usage:myInstance.cm.customItems[0].caption = "new text"
- Example:The example below changes the text of the first menu item.
theList.menu.customItems[0].caption = "new text";
strPasteInto
public var strPasteInto: String
Context Menu Item Paste Into string. Deprecated
The string of the paste into menu item. Deprecated. To change the text of any of the existing menu items use the contextMenu.customItems.caption property. Note: The Flash Player will not show the menu item if the caption is set to any of the reserved words, "cut, copy, paste".
- Usage:myInstance.cm.customItems[0].caption = "new text"
- Example:The example below changes the text of the first menu item.
theList.menu.customItems[0].caption = "new text";
strRemoveItem
public var strRemoveItem
Context Menu Item Remove string. Deprecated
The string of the remove menu item. Deprecated. To change the text of any of the existing menu items use the contextMenu.customItems.caption property. Note: The Flash Player will not show the menu item if the caption is set to any of the reserved words, "cut, copy, paste".
- Usage:myInstance.cm.customItems[0].caption = "new text"
- Example:The example below changes the text of the first menu item.
theList.menu.customItems[0].caption = "new text";
strRenameItem
public var strRenameItem
Context Menu Item Rename string. Deprecated
The string of the rename menu item. Deprecated. To change the text of any of the existing menu items use the contextMenu.customItems.caption property. Note: The Flash Player will not show the menu item if the caption is set to any of the reserved words, "cut, copy, paste".
- Usage:myInstance.cm.customItems[0].caption = "new text"
- Example:The example below changes the text of the first menu item.
theList.menu.customItems[0].caption = "new text";
symbolName
static var symbolName: String
The name of the ActionScript class
String: The name of the ActionScript class. Contains "dndList".
symbolOwner
static var symbolOwner: Object
The fully qualified class name
Static: The fully qualified class name (for example, mypackage.MyComponent). This variable is used in the internal call to the createClassObject() method.
targetItem
public var targetItem: Object
Reference to the target item after drag and drop
Item. Reference to the target item during drag and drop operation. The targetItem is the item that the mouse was over when a drop event occured. This item is set each time after a successful drag and drop or paste operation.
- Usage:myInstance.targetItem;
- Example:The example below traces the targetItem label.
trace("Last item dropped on " + theList.targetItem.label);
theCopyGridItems
public var theCopyGridItems: Array
Reference to array of datagrid items created on cut or copy events
Reference to array of datagrid items created on cut or copy events. This array is created when a user selects "Cut Item" or "Copy Item" from the context menu. This array also is created when the user calls the methods cutItem or copyItem. This array is created by converting the list items into datagrid items with the convertToGridItem method. This method can be redefined for your own use.
- Usage:myInstance.theCopyGridItems;
- Example:The example below returns the length of the array.
trace(theList.theCopyGridItems.length);
- See also:
theCopyItems
public var theCopyItems: Array
Reference to array of items created from cut or copy events
Reference to array of list items created from cut or copy events. This array is created when a user selects "Cut Item" or "Copy Item" from the context menu. This array also is created when the user calls the methods cutItem or copyItem.
- Usage:myInstance.theCopyItems;
- Example:The example below traces the length of the array.
trace(theList.theCopyItems.length);
theCopyNodes
public var theCopyNodes: Array
Reference to array of items converted to tree nodes on cut or copy events
Reference to array of items converted to tree nodes on cut or copy events. This array is created when a user selects "Cut Item" or "Copy Item" from the context menu. This array is also created when the user calls the methods cutItem or copyItem. This array is created by converting the list items into tree nodes with the convertToNode method. This method can be redefined for your own use.
- Usage:myInstance.theCopyNodes;
- Example:The example below traces the length of the copy nodes.
trace(theList.theCopyNodes.length);
- See also:
thePasteIntoItem
public var thePasteIntoItem: Object
Parent item where list items were pasted into
Object. Parent item where list items were pasted into. This property is set after a successful add, drop or paste event. This property is not supported in this version of the list but may be used in future versions.
- Usage:theItemSource = myInstance.thePasteIntoItem;
- Example:The example returns the parent item of list items that were most recently pasted.
parentItem = theList.thePasteIntoItem;
- See also:
thePasteToPosition
public var thePasteToPosition: Number
Relative index in the parent item where list items were pasted into
Number. Relative index in the list where the list items were pasted or dropped into. This property is set after a successful add, drop or paste event.
- Usage:pasteToPosition = myInstance.thePasteToPosition;
- Example:The example returns the paste to position.
pastePosition = theList.thePasteToPosition;
- See also:
toolTipDelay
public var toolTipDelay: Number
Tooltip delayed response in milliseconds
Tooltip delayed response in milliseconds. This is the amount of time to wait before showing the tooltip.
- Usage:myInstance.toolTipDelay = 300;
- Example:This example the tool tip delay to 300 milliseconds.
theList.toolTipDelay = 300;
- See also:
toolTipDepth
public var toolTipDepth: Number
Tooltip depth
Tooltip depth. This is the depth that the tooltip will be created at on the root movieclip.
- Usage:myInstance.toolTipDepth = 1000;
- Example:This example the tool tip depth to 2000.
theList.toolTipDepth = 2000;
- See also:
trackDebug
public var trackDebug: Boolean
Track debug messages in errorMsg variable
Track debug messages in the errorMsg variable. Trace this to see the event log. Deprecated. Use the support forums for help.
- Usage:myInstance.trackDebug = true;
- Example:The example below tracks debug information in the errorMsg variable.
theList.trackDebug = true;
trashCan
public var trashCan: MovieClip
Deprecated. Since version 2
Reference to a movieclip to use as a trashcan. Deprecated
Movieclip. Reference to a movieclip to use as a trashcan. There is an associated class that goes with this. Deprecated
- Usage:myInstance.trashCan = trashCan_mc;
- Example:The example sets a reference to a movieclip called trashcan_mc.
theList.trashCan = trashCan_mc;
versionNumber
public var versionNumber: String
Current version number for this component
Current version number for this component.
visible
public var visible: Boolean
Displays or hides the list
Displays the list when set to true. When set to false hides the list.
- Usage:myInstance.visible = true;
- Example:The example below displays the list.
theList.visible = true;
Property Documentation
copyIconX
public copyIconX: Number (write)
Sets the X coordinate for the copy icon
Number; Sets the X coordinate for the copy icon.
copyIconX
public copyIconX (read)
Gets the X coordinate for the copy icon
Number; Gets the X coordinate for the copy icon.
copyIconY
public copyIconY: Number (write)
Sets the Y coordinate for the copy icon
Number; Sets the Y coordinate for the copy icon.
copyIconY
public copyIconY (read)
Gets the Y coordinate for the copy icon
Number; Gets the Y coordinate for the copy icon.
enableContextMenu
public enableContextMenu: Boolean (read, write)
getterEnables or disables the right-click context menu
Enables context menu operations when set to true. When set to false no menu items appears when right-clicking on a item. The context menu is enabled by default. Certain functions can still be performed if drag and drop is enabled. This property can be set through the Component panel by changing "Enable Context Menu" parameter value.
- Usage:myInstance.enableContextMenu = newValue;
- Example:The example below enables the context menu.
// Example 1 - enable the context menu theList.enableContextMenu = true;
// Example 2 - Remove the rename menu item theList.cm.customItems.splice(7,1);
- See also:
Constructor Documentation
dndList
public function dndList (
)
Constructor used when creating a new list
Internal constructor used when creating a new theList instance. To create a dndList dynamically use the createClassObject method. The dndList must be in the library for this to work.
- Example:The example below creates a dndList at runtime.
// import the class import com.judah.controls.dndList; // create the list createClassObject(dndList,"dndList",this.getNextHighestDepth()); // set the size and position theList.setSize(240,250); theList._x = 10; theList._y = 70; // fill the list with data var arr:Array = new Array(); arr.push({label:"File 1",data:"file"}); arr.push({label:"File 1",data:"file"}); theList.dataProvider = arr; // style the list theList.setStyle("fontFamily", "_sans"); theList.setStyle("fontSize", 12);
Method Documentation
convertToGridItem
public function convertToGridItem (
theItem)
Converts single list item into a datagrid item
Converts a single list item into a datagrid item. Used when you drag and drop from a dndList to a dndDataGrid. It also copies any properties the list item may have. Redefine this method for your own use. The method is shown below.
- Example:
// default code used in this function. cater to your needs public function convertToGridItem(theItem) { //trace("\nconvertToGridItem()") // create new grid item from the list item var gridItem = new Object(); // loop through and add any properties // NOTE: This may copy references from the item for (var prop in theItem) { if (prop != "__ID__") { gridItem[prop] = theItem[prop]; } } return gridItem; }
convertToNode
public function convertToNode (
theItem)
Converts single list item into a tree node
Converts a single list item into a tree node. Used when you drag a list item onto a dndTree. It also copies any properties the list item may have. Redefine this method for your own use. The method is shown below.
- Example:
// default code used in this function. cater to your needs public function convertToNode(theItem) { //trace("convertToNode") // create new tree node from the list item properties var newXML = new XML('<node >'); var newXMLNode = newXML.firstChild; // get label from item if (theItem.label!=undefined) { newXMLNode.attributes.label = label; } // get data from item if (theItem.data!=undefined) { newXMLNode.attributes.data = theItem.data; } // get icon if it exists if (getItemIcon(theItem)!=undefined) { newXMLNode.attributes.icon = getItemIcon(theItem); } // NOTE: This may copy references for (var prop in theItem) { if (prop != "__ID__") { newXMLNode[prop] = theItem[prop]; } } return newXMLNode; }
copyItem
public function copyItem (
theItems,
eventSource)
eventSource)
A function to copy list items from the list
Method to copy list items from the list. A copyItem event is generated when this method is called. The event contains the target which is a reference to the list and the eventSource, which indicates if the method was called from the context menu. When the items are cut, copied or removed they are copied into the dndComponent.theCopyItems, dndComponent.theCopyNodes and the dndComponent.theCopyGridItems arrays. If enableCrossDrag property is true then the cut, copied or removed items will be available to any dndComponent that also has their cross drag property enabled.
- Parameters:
theItems - The selected item or items eventSource - Optional. Constant that refers to the source of the call. Typically list.MENU_EVENT - Returns:Reference to the copied list items
- Usage:myInstance.copyItem(theItems,eventSource);
- Example:The example below copies the selected item.
var copyItem = theList.copyItem(theList.selectedItem);
cutItem
public function cutItem (
theItems,
eventSource,
eventType)
eventSource,
eventType)
A function to cut items from the list
Method to cut items from the list. A cutItem event is generated when this method is called. The event contains the target which is a reference to the list and the eventSource, which indicates if the method was called from the context menu. When the items are cut, copied or removed they are copied into the dndComponent.theCopyItems, dndComponent.theCopyNodes and the dndComponent.theCopyGridItems arrays. If enableCrossDrag property is true then the cut, copied or removed items will be available to any dndComponent that also has their cross drag property enabled. Note: At this time you must select the items in the list first.
- Parameters:
theItems - The selected item or items eventSource - Optional. Constant that refers to the source of the call. Typically list.MENU_EVENT eventType - Optional. Constant that refers to the event of the call. If REMOVE_ITEM is passed in then a removeItem event is generated. - Returns:Reference to the cut list items
- Usage:myInstance.cutItem(theItems,eventSource,eventType);
- Example:The example below cuts the selected item from the list.
theList.selectedIndices = [0,1,2] var cutItem = theList.cutItem(theList.selectedItems);
drawSeparator
public function drawSeparator (
objPoint,
row,
dragOverPos,
bCanDrop)
row,
dragOverPos,
bCanDrop)
Draws separator line when dragging
Draws separator line when dragging. This method is provided for you to customize how the drag and drop looks to the user. Be careful not to do to many things in this function as it is run on every move and can tax the cpu. An interesting method is the row.setState method. This method highlights the row. Example code is shown below.
- Example:Here is the original function you can over write
// a lot of options are in the comments - you can uncomment to see what they do function drawSeparator(objPoint, row, dragOverPos, bCanDrop) { //var maxWidth = 24; var maxWidth = _width/2; //var maxWidth = objPoint.x - 5; //trace("maxWidth="+maxWidth) if (dragOverPos == PASTE_BEFORE) { separator._visible = true; if (row.state!="normal") { //row.setState("normal", false); } separator._y = row._y; } else if (dragOverPos == PASTE_AFTER) { separator._visible = true; //row.icon_mc._alpha = 100; //row.setState("normal", false); //row.icon_mc.gotoAndStop(1); // this unhighlights the row if (row.state!="normal") { //row.setState("normal", false); } separator._y = row._y + rowHeight; //trace("_rowHeight="+rowHeight) //trace("rowHeight="+rowHeight) } else if(dragOverPos == PASTE_INTO) { //separator._visible = false; // row.icon_mc._alpha = 100; // this highlights the row if (row.state!="highlighted") { //row.setState("highlighted", false); } separator._y = row._y + (rowHeight/2); //separator._y = objPoint.y; //row.icon_mc.gotoAndStop(2); // hide separator if we cannot drop //if (bCanDrop) { // trace("bCanDrop = true") // separator._visible = false; //} //else { // separator._visible = true; //} // } separator._alpha = 100; separator._width = maxWidth; separator._height = 1; separator.clear(); separator.lineStyle(1, 0x666666, 50); separator.moveTo(0, 0); separator.lineTo(width,0); //separator._y = objPoint.y; // we can track the depth that we are at but it doesn't look that good. //separator._x = row.nodeIcon._x; separator._x = 5; }
getIsBranch
public function getIsBranch (
item)
Method to determine if the item is a branch
Method to determine if the item is a branch. By default all items in the list are (leaf) items. You can use this function to tell theList that the item is a branch. Once that happens the list will allow you to drag and drop INTO "branch" rows. When a row has been determined to be a branch then the top and bottom section of the row becomes the PASTE_BEFORE and PASTE_AFTER zones. The space inbetween the top and bottom zones is called the PASTE_INTO zone. You can set the height of the PASTE_BEFORE and PASTE_AFTER zone by setting the dndGutter property. So, for example, if the row height is 20 pixels and you set the dndGutter to 5 pixels then the top 5 pixels of a row is the PASTE_BEFORE zone, the next 10 pixels is the PASTE_INTO zone and the bottom 5 pixels is the PASTER_AFTER zone.
- Parameters:
item Object Item in the list. - Usage:myInstance.getIsBranch = function(item) { return item.isBranch };
- Example:The example below checks if the item contains the isBranch property and returns true if it does.
// define the getIsBranch function theList.getIsBranch = function(item) { // if the item has a property called isBranch and it is true if (item.isBranch) { // this is branch return true; } return false; }
getIsOpen
public function getIsOpen (
theItem)
Method to check if item is open.
Method to check if item is open. Can be used to set bIsOpen and bIsNodeOpen property on cross dragged items. This is useful when dragging to a dndTree. This method returns false by default. Redefine for your own use.
- Returns:Boolean - True indicates item is open. False indicates item is closed.
- Example:The example defines when an item is determined to be open.
// define the getIsOpen function theList.getIsOpen = function(item) { // if the item has a property called isOpen // we check it to tell the list that this item is open if (item.isOpen) { // this is open return true; } return false; }
getItemIcon
public function getItemIcon (
theItem,
subIcon)
subIcon)
Gets the icon id of the item
Gets the icon id of the item. If the icon of the item is undefined and a substitute icon id is passed in then the substitute icon id is returned. There are built-in icons for your use. These are dndLeafIcon, dndIcon, dndIcon2, dndBranchIcon, dndBranchIconOpened, dndNoDropIcon, dndNoDropIcon2, dndCopyIcon and dndGenericIcon. See the styles example.
- Parameters:
theItem Object: The list icon subIcon String: Identifier of a substitute icon. Substitute icon is a movieclip. - Returns:String. Name of icon.
- Usage:myInstance.getItemIcon(myInstance.selectedItem);
- Example:
trace(theList.getItemIcon(theList.selectedItem));
getItemIndex
public function getItemIndex (
theItem)
Method to get index of item in list
Method to get index of item in list. Please use selectedIndex or selectedIndices before using this method.
- Parameters:
theItem Item in the list - Returns:Number If found returns the index of the item. If not found then returns -1
- Usage:myInstance.getItemIndex(item);
- Example:The example below gets the selected item index.
theList.getItemIndex(theList.selectedItem);
- See also:
getItemLabel
public function getItemLabel (
theItem,
subLabel)
subLabel)
Gets the label of the item
Gets the label of the item. If the label of the item is undefined and a substitute label is passed in then the substitute label text is returned.
- Parameters:
theItem Object The list item subLabel String The text to return if no label in the item is defined - Returns:String. Text of the label.
- Usage:myInstance.getItemLabel(item);
- Example:
trace(theList.getItemLabel(theList.selectedItem));
iconFunction
public function iconFunction (
item)
Method to dynamically set the icon of the row
Method to dynamically set the icon of the row. Normally it is set by reading the value of the item's "icon" property. This method will over write any default value. You can return undefined to return the default value. I also recommend you use this function rather than the iconField property for better control and compatibility.
- Overrides:mx.updatedcontrols.listclasses.ScrollSelectList.iconFunction in class mx.updatedcontrols.listclasses.ScrollSelectList
- Parameters:
item Object item in the list - Usage:myInstance.iconFunction = function(item) { return item.icon };
- Example:The example below sets an icon based on the icon property in the item.
// add items to the list theList.addItem({label:".. ",data:"folder"}); theList.addItem({label:"Folder 1",data:"folder"}); theList.addItem({label:"Folder 2",data:"folder"}); theList.addItem({label:"File 1",data:"file"}); theList.addItem({label:"File 2",data:"file"}); theList.addItem({label:"File 3",data:"file"}); // set the icon to use // we define the icons with this function. if we do not set it then no icons are created theList.iconFunction = function(item){ // get information from the selected item and use it to return linkage // to built in icons or icon movieclips in the library // both dndBranchIcon & dndIcon are built in icons var type = item.data; if (type=="folder") { return "dndBranchIcon"; } return "dndIcon"; } - See also:
labelFunction
public function labelFunction (
item)
Method to manually set the text of the row label
Method to manually set the text of the row label. You can use this function to display the label text of the row. Normally the label text is the value of the item's "label" property. This method will allow you to display whatever text you want based on what you return. You can return undefined to show the label value. I also recommend you use this function rather than the labelField property for better control and compatibility. You must redefine the setItemLabel function if you use the dndList rename feature because the labelFunction only renders the display label. The setItemLabel converts text entered into the rename field back to the label property. If the labelFunction is concatenating the label from multiple properties then you must redefine the setItemLabel.
- Overrides:mx.updatedcontrols.listclasses.ScrollSelectList.labelFunction in class mx.updatedcontrols.listclasses.ScrollSelectList
- Parameters:
item Object item in the list - Usage:myInstance.labelFunction = function(item) { return item.label };
- Example:The example below sets the label if the label is undefined.
//set the label to use theList.labelFunction = function(item) { // this label function checks if a label property exists // if it does not exist it uses the default value var label = item.label; if (label != undefined && label!="") { return label; } else { return "No Label Defined"; } } - See also:
modifyDragMC
public function modifyDragMC (
drag_mc)
Modifies the drag movieclip before dragging
Lets the user modify the drag movieclip before dragging and dropping rows. This movieclip only exists when a user starts dragging. It is the visual representation of the dragged contents. It contains many properties including gridItem, gridItems, node, nodes, item, items, dndReadOnly, multipleSelection, selectedIndex, selectedIndices, isDragging, moveAfterDropMode, owner, xOffset, yOffset, copyIcon, noDropIcon, nodeIcon0, bg_mc0, label_mc0 and origName. In addition to that each item in each of the arrays have the following properties:
item.bIsNodeBranch; item.bIsBranch; item.bIsNodeOpen; item.bIsOpen; item.owner item.indices item.itemIndex item.readOnly // self removing method item.removeMe()You can use the modifyDragMC function to modify the drag_mc before it is dragged.
- Parameters:
drag_mc Movieclip that is being dragged around - Usage:theList.modifyDragMC = function (theDrag_mc) { theDrag_mc.myProp = "Bill"; };
- Example:The example below adds a property to drag_mc.
theList.modifyDragMC = function (theDrag_mc) { theDrag_mc.myProp = "Bill"; trace(theDrag_mc.items.length); } - See also:
onContextMenuSelect
public function onContextMenuSelect (
)
User customizable function for manipulating the context menu
User customizable function for manipulating the context menu before it is shown. Use this or the permitContextMenu function to dynamically show or hide or enable or disable the menu items based on the item the user has selected at the time.
- Example:This function allows you to hide the first menu item
theList.onContextMenuSelect = function () { var customItems = theList.cm.customItems; customItems[0].visible = false; }
pasteItem
public function pasteItem (
theSourceItem,
theTargetItem,
pastePosition,
moveItem,
eventSource,
eventConstant)
theTargetItem,
pastePosition,
moveItem,
eventSource,
eventConstant)
Method to insert or move list items
Method to insert or move list items in the list at specific places. Please use addItem or addItemAt before using this method. A pasteItem event is generated when this method is called. The event contains the target, which is a reference to the list, the eventSource, which indicates if the method was called from the context menu, the target item and the pastePosition, which indicates the position above, below or in the target item. When items are cut, copied or removed they are copied into the dndComponent.theCopyItems, dndComponent.theCopyNodes and the dndComponent.theCopyGridItems arrays. If enableCrossDrag property is true then the cut, copied or removed items will be available to any dndComponent that also has their cross drag property enabled. When paste from the context menu this is where those items come from.
- Parameters:
theSourceItem The item or items that will be inserted into the list. This can be an object or object array. theTargetItem Object - The location or reference item of where the item(s) should be inserted. pastePosition Number Constant - Refers to the paste position (PASTE_INTO, PASTE_BEFORE, PASTE_AFTER). moveItem Boolean - Indicates to move or copy the list items from their original location. eventSource Number Constant - A constant used to indicate the source of the method. Also used to generate the appropriate events (pasteItem, drop, addItem). Value can be DROP_EVENT, MENU_EVENT or METHOD_CALL. If not specified a pasteItem event is generated. Optional. eventConstant Number Constant - A constant used to indicate and generate an ADD_ITEM or ADD_BRANCH event. Optional. - Returns:Returns a reference to the item or an array of items. Same reference as selectedItem or selectedItems.
- Usage:myInstance.pasteItem(theItem, theTargetItem, pastePosition, moveItem);
- Example:The example below pastes an item at the top of the list.
// assign the index to the list item theList.dataProvider[1].itemIndex = 1 if (theList.selectedItem!=theList.dataProvider[1]) { theList.pasteItem(theList.selectedItem, theList.dataProvider[1], theList.PASTE_BEFORE, true); } theList.pasteItem(theList.selectedItem, theList.dataProvider[0], theList.PASTE_BEFORE, true); - See also:
permitContextMenu
public function permitContextMenu (
theItem,
theAction,
theMenuItem,
theContextMenu)
theAction,
theMenuItem,
theContextMenu)
A user defined function to display context menu items
A user defined function to show or hide context menu items on an item by item basis. This function is called when the menu is created and allows you to show or hide menu items based on the list item being passed in. Be aware that the scope changes in this function. The default value returned by this function is true meaning all menu items are shown.
- Parameters:
theItem Object - The selected item theAction Number Constant - Reference to a static event variable if one is assigned such as (PASTE_INTO, PASTE_BEFORE, PASTE_AFTER, ADD_ITEM, etc). theMenuItem ContextMenu - Reference to the context menu theContextMenu Object - Reference to custom item object - Returns:Boolean
- Usage:myInstance.permitContextMenu = function(theItem,theAction,theMenuItem,theContextMenu) {};
- Example:The code below is the default code in the permitContextMenu function. The code hides the "Paste Into" menu item unless the item is a branch, preventing a user from pasting the copied item into another item.
theList.permitContextMenu = function (theItem, theAction, theMenuItem, theContextMenu) { // "this" keyword does **NOT** reference the list here because we are in a different scope // use the list instance name directly // theList.PASTE_INTO is a static variable for paste into // if the action is to paste into then we allow it on branch items if (theAction==theList.PASTE_INTO) { // we are checking if the item we selected is a branch item // if true then we show the "paste into" menu item if (theList.getIsBranch(theItem)) { return true; } else { return false; } } return true; } // if we define this function we can use it to let the dndList drop INTO another row // when a user is dragging over a row that is defined as a branch theList.getIsBranch = function(item){ var type = item.data; if (type=="folder") { return true; } return false; }
permitDropFunction
public function permitDropFunction (
theItem,
theTargetItem,
theAction)
theTargetItem,
theAction)
A user defined function to allow or prevent drop
A user defined function used to prevent or allow drop. This function is also used for visual feedback when the user is dragging over rows. This default value returned by this function is true. See permissions example.
- Parameters:
theItem Object - The selected item. theTargetItem Object - The target item. The item the mouse is over. theAction Number Constant - The current drag operation. This can be PASTE_INTO, PASTE_AFTER or PASTE_BEFORE. - Returns:Boolean
- Usage:myInstance.permitDropFunction = userFunctionName;
- Example:The example below prevents a user from dropping into anything but a branch item.
// add items to the list // we set the arbitrary fileType property for use in icon function theList.addItem({label:".. ",data:"green",icon:"folder",fileType:"parentFolder"}); theList.addItem({label:"Folder 1",data:"red",icon:"folder",fileType:"folder"}); theList.addItem({label:"Folder 2",data:"red",icon:"folder",fileType:"folder"}); theList.addItem({label:"File 1",data:"blue",icon:"file",fileType:"file"}); theList.addItem({label:"File 2",data:"blue",icon:"file",fileType:"file"}); theList.addItem({label:"File 3",data:"blue",icon:"file",fileType:"file"}); // the permit drop function is used when dragging and dropping theList.permitDropFunction = function (theSourceItem, theTargetItem, theAction) { // we are in a different scope. the keyword "this" references the dndList //trace("theSourceItem ="+theSourceItem.label); //trace("theTargetItem ="+theTargetItem.label); // we are checking if the item we are dragging over is a branch item // we have to define the getIsBranch method to enable dropping into an item. // if true then we can paste into it. if not then no pasty // we return false to prevent a drop from occuring // returning false also shows the "no drop" allowed icon if (this.getIsBranch(theTargetItem)) { // this.PASTE_INTO is a static variable for paste into // if the action is to paste into then we allow it if (theAction==this.PASTE_INTO) { return true; } } // if we are not dragging into the branch we do not allow it return false; } // define the getIsBranch function theList.getIsBranch = function(item) { // if the item has a property called isBranch and it is true if (item.fileType=="folder") { // this is branch return true; } return false; }
permitRemove
public function permitRemove (
obj,
menuItem,
menuCaption,
eventType)
menuItem,
menuCaption,
eventType)
Lets the user show an alert before a cut or remove event
Lets the user show an alert before a cut or remove event. You can define this to pop up an alert prompt similar to windows explorer. Because of the nature of the Alert component we cannot get the button clicked syncronously. Therefore, we have to manually call the method we would have performed when the user clicks the OK button. See permissions example.
- Parameters:
obj Object - The list. menuItem Object - The menuItem. menuCaption String - The caption of the menu item. eventType String - The current event operation. This can be REMOVE_ITEM or CUT_ITEM. - Returns:Boolean Returns false to prevent cut or remove. Return true to continue cut or remove.
- Usage:myInstance.permitRemove = functionName;
- Example:The example prompts the user before removing the selected item.
// import the alert contol - add to the library import mx.controls.Alert; // prompt user on remove event theList.permitRemove = function (theDataGrid, menuItem, menuCaption, eventType) { // BE CAREFUL of SCOPE ISSUES HERE var itemLabel = theList.selectedItem.label; var eventName = "cut"; var output = ""; // check if this is a remove event if (eventType == theList.REMOVE_ITEM) { eventName = "remove"; } myClickHandler = function (evt) { if (evt.detail == Alert.OK) { theList.cutItem(theList.selectedItems, theList.MENU_EVENT, eventType); } } output = "Are you sure you want to " + eventName + " " + itemLabel + "?"; var myAlert = Alert.show(output, "Confirm File Delete", Alert.OK | Alert.CANCEL, this, myClickHandler, "stockIcon", Alert.OK); return false; }
permitRename
public function permitRename (
theItem)
A user defined function to allow rename on a item
A user defined function to show the rename textfield on a item. If this function returns false then no rename textfield will be shown for the selected item. This is useful if you do not want to show a rename textfield on specific items such as the branch items. If you want to prevent the "Rename Item" in the context menu use permitContextMenu function.
- Parameters:
theItem Object - The selected item - Returns:Boolean Return true to show rename text field. Return false to not show rename text field.
- Usage:myInstance.permitRename = function(theItem) { return true };
- Example:The example below hides the rename text field on branch items.
theList.permitRename = function (theItem) { if (theItem==undefined) { return false; } // we are in a different scope. the keyword "this" references the theList // check if the item is a branch item if (theList.getIsBranch(theItem)) { // if it is then do not show the rename text field return false; } return true; } - See also:
removeClipboardItems
public function removeClipboardItems (
)
removes items from copy and paste clipboard
renameFunction
public function renameFunction (
rowIndex,
eventSource)
eventSource)
Lets the user override the normal rename method
Lets the user override the normal rename method. You can use this function to override the default behavior.
- Parameters:
rowIndex Number - The row index eventSource Number - The event source. Either a MENU_EVENT or METHOD_CALL. Optional - Usage:myInstance.renameFunction = function(row,eventSource) {};
- Example:The code below is the default code
// The code below is the default code function renameFunction (rowIndex, eventSource) { // show the rename textfield showRenameItem(rowIndex, eventSource); }
setItemLabel
public function setItemLabel (
theItem: Object,
labelText: String,
originalText: String): String
labelText: String,
originalText: String): String
A method to call to set the item label
A method to call to set the item label on rename. If the labelFunction function is defined then when the user renames the item the new text is passed on to this method and the label can be set manually. If the labelField property is defined then the labelText string is applied to that. If neither of these two properties are defined then the new text is assigned to the item.label property. If you define the labelFunction and you want the rename feature to work you may need to redefine this function.
- Parameters:
theItem Object - The item that is being renamed. labelText String - The new text for the label. originalText String - The original text of the label. - Returns:String. A string of the new label text.
- Usage:myInstance.setItemLabel(theItem);
- Example:The default code for the setItemLabel is below.
public function setItemLabel (theItem:Object, labelText:String, originalText:String):String { var retVal; //NOTE: User may need to redefine this function if they define the labelFunction // if an label field exists then set the text to that if (labelField != undefined) { theItem[labelField] = labelText; retVal = labelText; } else { // labelField is not set use default label property theItem.label = labelText; retVal = labelText; } return retVal; }
showRenameItem
public function showRenameItem (
rowIndex: Number,
eventSource)
eventSource)
Shows renaming textfield over row
Shows a textfield over row that the user can type into to rename the item label. The rename textfield is instantiated when the enableRenameItem is true. The user can select to rename from the context menu or on double click or both. To prevent renaming on double click disable the renameOnDoubleClick property. This is mostly an internal method.
- Parameters:
rowIndex Number Row index. eventSource - Example:
// shows the rename text field on the first visible row theList.showRenameItem(0);
- See also:
showToolTip
public function showToolTip (
)
Method to display tooltip
Method to display tooltip.
- See also:
toolTipFunction
public function toolTipFunction (
row_mc)
Method to modify tooltip movieclip directly after it has been created
Method to modify tooltip movieclip directly after it has been created.
- Parameters:
row_mc Row that contains the textfield that is used as the tooltip - Example:This is the code of the tooltip function
function toolTipFunction(row_mc) { // determine if we are using a cell renderer by checking if cell has the renameField or a textfield we know exists in our cellrenderer var bCellRenderer:Boolean = (row_mc.cll.renameField != undefined) ? true : false; // get a reference to the row label - you may need to point this to your textfield var rowLabel = (bCellRenderer) ? row_mc.cll.renameField : row_mc.cll; // set selectable to false to prevent text cursor rowLabel.selectable = false; // set border color, border and background rowLabel.setStyle("borderColor",0xD5DDDD); rowLabel.border = true; rowLabel.background = true; // some properties i've turned off but could be enabled //rowLabel.autoSize = "left"; //rowLabel.wordWrap = true; //rowLabel.multiline = true; // autosize text field rowLabel.autoSize = "center"; // snap cell (label) to the left edge of the row which is positioned next to the mouse row_mc.cell._x = 0; }
validateItemLabel
public function validateItemLabel (
newText: String,
renameTextField: TextField): Boolean
renameTextField: TextField): Boolean
Validates renamed item labels
Allows the developer to validates values entered when a user renames a item.
- Parameters:
newText String - The item or items that will be inserted into the list. renameTextField TextField - The current rename textfield. - Returns:Boolean - True allows the item label to be renamed. False cancels the changes, enters the original value and highlights the text.
- Example:The method code is shown below.
// this lets the user enter anything besides blank text theList.validateItemLabel = function(newText, renameTextField) { // check if new text user entered is blank if (newText=="") { // restore original text renameTextField.text = renameTextField.orgText; // reselect text and cancel commit Selection.setSelection(0, renameTextField.length); return false; } else { // new text is not blank. allow rename return true; } }
- dndList.as, Last Modified: 6/16/2006 1:34:06 AM