This is an automated email from the ASF dual-hosted git repository.
carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new bf407b2 searchfilterforlist bead: select the item in the list (or in
the combobox) if the text is equal to the text inserted. for multiple matches
selects the fist one in the list
bf407b2 is described below
commit bf407b2db1dfa3e59a1076d33db2181652ead5c7
Author: Carlos Rovira <[email protected]>
AuthorDate: Tue Feb 19 15:53:23 2019 +0100
searchfilterforlist bead: select the item in the list (or in the combobox)
if the text is equal to the text inserted. for multiple matches selects the
fist one in the list
---
.../controls/textinput/SearchFilterForList.as | 32 +++++++++++-----------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/SearchFilterForList.as
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/SearchFilterForList.as
index 583fc67..62f0a98 100644
---
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/SearchFilterForList.as
+++
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controls/textinput/SearchFilterForList.as
@@ -129,31 +129,31 @@ package org.apache.royale.jewel.beads.controls.textinput
{
var ir:ListItemRenderer;
var numElements:int = list.numElements;
- // var count:uint = 0;
- // var lastActive:ListItemRenderer = null;
- while (numElements--)
+ var item:Object = null;
+ while (numElements--)
{
ir = list.getElementAt(numElements) as ListItemRenderer;
if (filterFunction(ir.text, filterText))
{
ir.visible = true;
- // lastActive = ir;
- // count++;
+
+ //stores the item if text is the same
+ if(ir.text.toUpperCase() == filterText)
+ {
+ item = ir.data;
+ }
} else {
ir.visible = false;
}
}
- // if (lastActive != null && list.selectedItem !=
lastActive.data)
- // {
- // list.selectedItem = lastActive.data;
- // } else
- // {
- // list.selectedItem = null;
- // }
- /* if (count == 1) {
- //select lastActive if there is only one that
matches?
- }*/
- }
+ //Select the item in the list if text is the same
+ // we do at the end to avoid multiple selection (if
there's more than one matches)
+ // in that case, select the first one in the list
+ if(item != null)
+ {
+ list.selectedItem = item;
+ }
+ }
}
}