-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pushing two changes: 1. Addition of FocusOut 2. Changes to the 'select' to call List.CHANGE after setting current selected item index.
- Loading branch information
Showing
1 changed file
with
18 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,15 +15,17 @@ Copyright 2009, Matthew Eernisse ([email protected]) and Slide, Inc. | |
*/ | ||
|
||
package org.flex_pilot { | ||
import org.flex_pilot.events.*; | ||
import org.flex_pilot.FPLocator; | ||
import flash.events.* | ||
import flash.utils.*; | ||
import flash.geom.Point; | ||
import flash.display.DisplayObject; | ||
import flash.display.DisplayObjectContainer; | ||
import mx.events.* | ||
import flash.events.*; | ||
import flash.geom.Point; | ||
import flash.utils.*; | ||
|
||
import mx.controls.DateField; | ||
import mx.events.*; | ||
|
||
import org.flex_pilot.FPLocator; | ||
import org.flex_pilot.events.*; | ||
|
||
public class FPController { | ||
public function FPController():void {} | ||
|
@@ -283,29 +285,23 @@ package org.flex_pilot { | |
charCode: currCode }); | ||
} | ||
} | ||
|
||
public static function focusOut(params:Object):void { | ||
var obj:* = FPLocator.lookupDisplayObject(params); | ||
Events.triggerFocusEvent(obj, FocusEvent.FOCUS_OUT); | ||
} | ||
public static function select(params:Object):void { | ||
// Look up the item to write to | ||
var obj:* = FPLocator.lookupDisplayObject(params); | ||
var sel:* = obj.selectedItem; | ||
var item:*; | ||
// Give the item focus | ||
Events.triggerFocusEvent(obj, FocusEvent.FOCUS_IN); | ||
function selectByIndex(idx:*):void { | ||
obj.selectedIndex = idx; | ||
} | ||
function selectByItem(item:*):void { | ||
obj.selectedItem = item; | ||
} | ||
function setComboboxSelection(setter:Function, newValue:*):void { | ||
setter(newValue); | ||
Events.triggerListEvent(obj, ListEvent.CHANGE); | ||
} | ||
// Set by index | ||
switch (true) { | ||
case ('index' in params): | ||
if (obj.selectedIndex != params.index) { | ||
setComboboxSelection(selectByIndex, params.index); | ||
obj.selectedIndex = params.index; | ||
Events.triggerListEvent(obj, ListEvent.CHANGE); | ||
} | ||
break; | ||
case ('label' in params): | ||
|
@@ -317,9 +313,10 @@ package org.flex_pilot { | |
if (sel[labelField] != targetLabel) { | ||
for each (item in obj.dataProvider) { | ||
if (item[labelField] == targetLabel) { | ||
setComboboxSelection(selectByItem, item); | ||
obj.selectedItem = item; | ||
} | ||
} | ||
Events.triggerListEvent(obj, ListEvent.CHANGE); | ||
} | ||
break; | ||
case ('data' in params): | ||
|
@@ -328,9 +325,10 @@ package org.flex_pilot { | |
if (sel.data != targetData) { | ||
for each (item in obj.dataProvider) { | ||
if (item.data == targetData) { | ||
setComboboxSelection(selectByItem, item); | ||
obj.selectedItem = item; | ||
} | ||
} | ||
Events.triggerListEvent(obj, ListEvent.CHANGE); | ||
} | ||
break; | ||
default: | ||
|