[josm-dev] MapMode Button State
Holger Mappt
holgerosm at gmx.net
Thu Oct 24 19:05:30 UTC 2013
Hi,
I created a map mode based on MapMode and an IconToggleButton that is
added to the MapFrame. The map mode works with objects on an overlay
layer (photos of the GeoImageLayer). The goal is to enable the button
if there is at least one GeoImageLayer with at least one photo loaded
and to disable/hide it otherwise. The button method
setAutoHideDisabledButton(true) is called to hide the button if there is
nothing to do for my map mode. Depending on the MapMode methods that I
implement the button state can be enabled, disabled but visible, or hidden.
Question: How can I implement the intended map mode button behavior? Is
there a good example?
MapMode.layerIsSupported() seems to be the only method that JOSM
supports to set the button state. But it doesn't work in my case
because the active layer doesn't matter. MapMode.updateEnabledState()
is implemented by some other MapModes, but I don't understand how it is
connected to the button. The MapMode is the button action, but I want
to disable the button, not the action. I can call
IconToggleButton.setEnabled(), but MapView.setActiveLayer() overwrites
it if the layer is switched. What else can I do?
Thanks,
Holger
More information about the josm-dev
mailing list