Skip to content

Commit c9cd22a

Browse files
author
stevage
committed
Fix #3367. Every time the Background dropdown is opened now, it checks to see if it needs to update its selectedIndex.
git-svn-id: http://svn.openstreetmap.org/applications/editors/potlatch2@25524 b9d5c4c9-76e1-0310-9c85-f3177eceb1e4
1 parent 2b28e1b commit c9cd22a

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

net/systemeD/potlatch2/BackgroundSelector.mxml

+9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@
3030
import mx.collections.ArrayCollection;
3131
import mx.managers.PopUpManager;
3232
33+
/** Sets the currently selected item by consulting Imagery.instance() */
34+
public function updateSelectedIndex() {
35+
if(background.selectedIndex==-1) {
36+
var im:Imagery = Imagery.instance();
37+
var i = im.collection.indexOf(im.findBackgroundWithName(im.selected.name));
38+
background.selectedIndex = i;
39+
}
40+
}
41+
3342
public function setDimming(v:Boolean):void {
3443
Application.application.theMap.setDimming(dim.selected);
3544
Application.application.yahoo.alpha = dim.selected ? 0.5 : 1;

net/systemeD/potlatch2/collections/Imagery.as

+9-7
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ package net.systemeD.potlatch2.collections {
1010
import net.systemeD.potlatch2.FunctionKeyManager;
1111
import net.systemeD.potlatch2.Yahoo;
1212
import mx.collections.ArrayCollection;
13-
14-
/*
15-
There's lots of further tidying we can do:
16-
- remove all the horrid Yahoo stuff
17-
- remove the backreferences to _map and send events instead
18-
but this will do for now and help remove the clutter from potlatch2.mxml.
13+
14+
/** Manages the different choices of background imagery, dealing with details like retrieving lists of imagery,
15+
* saving and retrieving the current choice, etc.
16+
*
17+
* TODO There's lots of further tidying we can do:
18+
* - remove all the horrid Yahoo stuff
19+
* - remove the backreferences to _map and send events instead
20+
* but this will do for now and help remove the clutter from potlatch2.mxml.
1921
*/
2022

2123
public class Imagery extends EventDispatcher {
@@ -172,7 +174,7 @@ package net.systemeD.potlatch2.collections {
172174
obj.flush();
173175
}
174176

175-
private function findBackgroundWithName(name:String):Object {
177+
public function findBackgroundWithName(name:String):Object {
176178
for each (var bg:Object in collection) {
177179
if (bg.name==name) { return bg; }
178180
}

potlatch2.mxml

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
<mx:ApplicationControlBar dock="true">
3131
<mx:PopUpButton id="bgButton" label="Background" openAlways="true" styleName="appBarButton"
32-
creationComplete="bgButton.popUp = new BackgroundSelector();"/>
32+
creationComplete="bgButton.popUp = new BackgroundSelector();"
33+
open="(bgButton.popUp as BackgroundSelector).updateSelectedIndex();"/>
3334
<mx:PopUpButton id="styleButton" label="Map Style" openAlways="true" styleName="appBarButton"
3435
creationComplete="styleButton.popUp = new StyleSelector();"/>
3536
<mx:PopUpMenuButton id="gpsButton" styleName="appBarButton"

0 commit comments

Comments
 (0)