Select to view content in your preferred language

Combobox Events

950
5
12-09-2010 12:15 PM
CaseyBentz
Frequent Contributor
Good afternoon all,

I am attempting to use a combo box to select and zoom to an area.  This works great until the user pans around and decides that they want to select and zoom to the area they already have selected.  The problem lies in that when the user selects the same item, only the close event fires.  The close event also fires when the user hits esc key, clicks the combo box button, or clicks anywhere else on the page.  The biggest problem I see is that it appears that the close event cannot determine if you clicked an item in the list to close or just hit esc or whatever.  Does anyone have any ideas of how to handle this sort of navigation?
Tags (2)
0 Kudos
5 Replies
DasaPaddock
Esri Regular Contributor
Maybe on the next extentChange event you could reset the selectedIndex of the ComboBox since it's no longer "valid".
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Casey,

   I think what you are talking about is how to have some event fired even if it is the same item selected in the combobox. If that is the case then here is a solution that has some draw backs:

<s:ComboBox id="cb1" open="cb1.selectedIndex = -1" change="trace(cb1.selectedItem)">
  <s:ArrayList>
   <fx:String>Red</fx:String>
   <fx:String>Green</fx:String>
   <fx:String>Blue</fx:String>
  </s:ArrayList>
 </s:ComboBox>

The good part is the changed event will be fired even if the user selects the same item.
The bad part is if the use hits esc key then there is no longer a active selection in the CB

Hope this helps
0 Kudos
CaseyBentz
Frequent Contributor
Robert, I tried this method yesterday as well.  I need the selectedItem to remain even if the user hits esc.  I have been racking my brain and have come up with 2 possible solutions.  One would be to somehow extend the standard combobox by adding an itemClick event.  I have never done something like this and am not sure if it is even possible.  My other idea is to use a popup menu and add a list  and use it in place of the combobox.  Any thoughts on these 2 ideas? 

I am also attempting to figure out how to update the field aliases in my MXD.  The MXD I have is old and was built prior to a standardization of the field aliases.  I am thinking there must be a way to do this using arcpy.  Like list all the fields in each layer in the map.  Then list all the feature classes in a data set and search for the feature class and then for the field name from a list of all the fields from that feature class and then read the alias and use that to set the alias of the layer in the map.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Casey,

   Here is another route

private var cbSelectedIndx:Number = -1;
   
   private function cbOpen():void
   {
    cbSelectedIndx = cb1.selectedIndex;
    cb1.selectedIndex = -1;
   }
   
   private function cbClosed():void
   {
    if(cb1.selectedIndex == -1)
     cb1.selectedIndex = cbSelectedIndx;
   }
<s:ComboBox id="cb1" open="cbOpen()" change="trace(cb1.selectedItem)" close="cbClosed()">
  <s:ArrayList>
   <fx:String>Red</fx:String>
   <fx:String>Green</fx:String>
   <fx:String>Blue</fx:String>
  </s:ArrayList>
 </s:ComboBox>
0 Kudos
CaseyBentz
Frequent Contributor
Perfect. Thanks as always. In this new forum I have no idea how or even if I can mark this as answered. But thanks for answering this post. I was ready to give up hope.
0 Kudos