Forum Discussion
fernando_miguel
12 years agoOccasional Contributor
I managed to get the the ClickPopUpMenuItem() working as a workaround.
The key was:
* Keep it menu opened using "open()" instead of "Click()".
* Change root object to search.
However Firefox keeps crashing and I think that BUG should be solved anyway.
Resulting ClickPopUpMenuItem() stays as follows:
function ClickPopUpMenuItem(PopUpMenuButton, ItemText) {
var AppObject, ItemObject, PropNames, PropValues;
//PopUpMenuButton.Click(PopUpMenuButton.Width-5, PopUpMenuButton.Height/2);
//Instead of clicking we call open that leaves the popup control opened even
//if focus is lost (e.g. when stepping).
PopUpMenuButton.FlexObject.open();
// Obtain the Flex application object
AppObject = PopUpMenuButton.Parent;
// Example was looking for first parent not being an object but we
// need just the opposite, we need it to be an object
while (AppObject.ObjectType != "Object")
{
AppObject = AppObject.Parent
}
// Find a pop-up menu item by text
PropNames = new Array("ObjectType", "FlexObject.listData.label");
PropValues = new Array("MenuItemRenderer", ItemText);
ItemObject = AppObject.FindChild(PropNames, PropValues, 5);
if(ItemObject.Exists) {
//PopUp menu is automatically closed when clicking on an item
ItemObject.Click();
} else {
//We leave the menu closed
PopUpMenuButton.FlexObject.close();
Log.Error("PopUpMenuButton item '" + ItemText + "' was not found.");
}
}
The key was:
* Keep it menu opened using "open()" instead of "Click()".
* Change root object to search.
However Firefox keeps crashing and I think that BUG should be solved anyway.
Resulting ClickPopUpMenuItem() stays as follows:
function ClickPopUpMenuItem(PopUpMenuButton, ItemText) {
var AppObject, ItemObject, PropNames, PropValues;
//PopUpMenuButton.Click(PopUpMenuButton.Width-5, PopUpMenuButton.Height/2);
//Instead of clicking we call open that leaves the popup control opened even
//if focus is lost (e.g. when stepping).
PopUpMenuButton.FlexObject.open();
// Obtain the Flex application object
AppObject = PopUpMenuButton.Parent;
// Example was looking for first parent not being an object but we
// need just the opposite, we need it to be an object
while (AppObject.ObjectType != "Object")
{
AppObject = AppObject.Parent
}
// Find a pop-up menu item by text
PropNames = new Array("ObjectType", "FlexObject.listData.label");
PropValues = new Array("MenuItemRenderer", ItemText);
ItemObject = AppObject.FindChild(PropNames, PropValues, 5);
if(ItemObject.Exists) {
//PopUp menu is automatically closed when clicking on an item
ItemObject.Click();
} else {
//We leave the menu closed
PopUpMenuButton.FlexObject.close();
Log.Error("PopUpMenuButton item '" + ItemText + "' was not found.");
}
}