Select to view content in your preferred language

API 2.0 - Cursor issue with map context menu

1179
12
06-29-2010 10:57 AM
TonyCollins
Regular Contributor
Hi there,

Using API 2.0, the standard context menu (on right click) has no mouse pointer when in pan mode (NavigationTool.PAN).

Is this something I am doing/can be fixed?

Thanks
Tony
Tags (2)
0 Kudos
12 Replies
RobertScheitlin__GISP
MVP Emeritus
Tony,

   OK glad to see that I am not the only one noticing that issue. It is not limited to the pan mode though. No matter what tool or cursor is set when you right click and hover over a context menu the mouse cursor is completely gone until you dismiss that context menu.
0 Kudos
TonyCollins
Regular Contributor
Hi Robert,

I'm only getting the issue when the pan control's custom cursor is active. Do you have any custom cursors for your other tools?

I did think it might be my contextmenu, but the issue is still there when I remove it.


Tony,

   OK glad to see that I am not the only one noticing that issue. It is not limited to the pan mode though. No matter what tool or cursor is set when you right click and hover over a context menu the mouse cursor is completely gone until you dismiss that context menu.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Tony,

   Yep, almost all my tools have custom cursors.
0 Kudos
DasaPaddock
Esri Regular Contributor
Are you able to reproduce this issue in the Sample?
http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=NavigationTools
If not, can you post a test case?
0 Kudos
TonyCollins
Regular Contributor
Are you able to reproduce this issue in the Sample?
http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=NavigationTools
If not, can you post a test case?


Hi,

I notice on the example you post (for me anyway) that the pan cursor is only visible when the map is being dragged.

In my app when Pan is enabled the pan cursor is always visible until I switch tool to something else.

Does this make sense?
0 Kudos
ReneRubalcava
Honored Contributor
Same issue here. Never noticed before, but only happens in IE7 with Flash 10,1,53,64 debugger.
Works as expected in my Chrome install with Flash 10,0,45,2 installed

Only 2 setups I can test at the moment, so can't narrow it to browser or flash installs.

But in any 2.0 app, final or beta, I get no mouse cursor in the Context Menu. In the example you linked, if I am in Zoom Navigation, I do get a mouse cursor.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Dasa,

   Here is my test case. I believe you will find it has something to do with the NavTool.deactivate which is what I think Tony is seeing also.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:esri="http://www.esri.com/2008/ags"
      pageTitle="Basic usage of DrawTool">
 
 <s:layout>
  <s:VerticalLayout paddingBottom="5"/>
 </s:layout>
 
 <fx:Style>
  @namespace mx "library://ns.adobe.com/flex/mx";  
  mx|ToolTip
  {
   font-size: 14;
  }
 </fx:Style>
 
 <fx:Script>
  <![CDATA[
   import com.esri.ags.events.DrawEvent;
   import com.esri.ags.geometry.MapPoint;
   import mx.controls.Alert;
   import com.esri.ags.Graphic;
   import spark.events.IndexChangeEvent;
   import com.esri.ags.events.GraphicEvent;
   
   private var menuItem:ContextMenuItem = new ContextMenuItem("Remove Me");
   
   private function init(evt:Event):void
   {
    myGraphicsLayer.addEventListener(GraphicEvent.GRAPHIC_ADD,addContextMenu);
    menuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, removeMeMenuItemHandler);
    navTool.activate(NavigationTool.PAN);
   }
   
   private function removeMeMenuItemHandler(event:ContextMenuEvent):void
   {
    var graphic:Graphic = event.contextMenuOwner as Graphic;
    graphic.dispatchEvent(new Event("removeMe", true));
   }
   
   private function addContextMenu(evt:Event):void
   {
    var gLyr:GraphicsLayer = evt.target as GraphicsLayer;
    myGraphicsLayer.addEventListener("removeMe", graphicRemoveMeHandler);
    for each (var g:Graphic in gLyr.graphicProvider)
    {
     if (g.contextMenu == null)
     {
      var contextMenu:ContextMenu = new ContextMenu();
      contextMenu.hideBuiltInItems();
      contextMenu.customItems.push(menuItem);
      if (g.geometry.type.toUpperCase() == "ESRIGEOMETRYPOINT")
      {
       var mp:MapPoint = g.geometry as MapPoint;
       var menuItem2:ContextMenuItem = new ContextMenuItem("X: " + numFormatter2.format(mp.x) + ", Y: " + numFormatter2.format(mp.y));
       contextMenu.customItems.push(menuItem2);
      } 
      g.contextMenu = contextMenu;
     }
    }
   }
   
   private function graphicRemoveMeHandler(event:Event):void
   {
    var gLyr:GraphicsLayer = event.currentTarget as GraphicsLayer;
    var graphic:Graphic = event.target as Graphic;
    var gObj:Object = myGraphicsLayer.graphicProvider;
    
    for (var i:int = myGraphicsLayer.numGraphics - 1; i >= 0; i--)
    {
     if(myGraphicsLayer.graphicProvider.name == graphic.name)
      myGraphicsLayer.remove(myGraphicsLayer.graphicProvider);
    } 
   }
   
   protected function bb_changeHandler(event:IndexChangeEvent):void
   {
    if (event.newIndex == -1)
    {
     drawTool.deactivate();
     navTool.activate(NavigationTool.PAN);
     navTool.deactivate();
    }
    else
    {
     switch (bb.dataProvider.getItemAt(event.newIndex))
     {
      case "Point":
       navTool.deactivate();
       drawTool.activate(DrawTool.MAPPOINT);
       break;
      case "Multipoint":
       navTool.deactivate();
       drawTool.activate(DrawTool.MULTIPOINT);
       break;
      case "Single Line":
       navTool.deactivate();
       drawTool.activate(DrawTool.LINE);
       break;
      case "Polyline":
       navTool.deactivate();
       drawTool.activate(DrawTool.POLYLINE);
       break;
      case "FreeHand Polyline":
       navTool.deactivate();
       drawTool.activate(DrawTool.FREEHAND_POLYLINE);
       break;
      case "Polygon":
       navTool.deactivate();
       drawTool.activate(DrawTool.POLYGON);
       break;
      case "Freehand Polygon":
       navTool.deactivate();
       drawTool.activate(DrawTool.FREEHAND_POLYGON);
       break;
      case "Rectangle":
       navTool.deactivate();
       drawTool.activate(DrawTool.EXTENT);
       break;
     }
    }
   }
  ]]>
 </fx:Script>
 
 <fx:Declarations>
  <!-- Symbol for all point shapes -->
  <esri:SimpleMarkerSymbol id="sms"
         color="0x00FF00"
         size="12"
         style="square"/>
  
  <!-- Symbol for all line shapes -->
  <esri:SimpleLineSymbol id="sls"
          color="0x00FF00"
          width="3"/>
  
  <!-- Symbol for all polygon shapes -->
  <esri:SimpleFillSymbol id="sfs"
          color="0xFFFFFF"
          style="diagonalcross">
   <esri:outline>
    <esri:SimpleLineSymbol color="0x00FF00" width="2"/>
   </esri:outline>
  </esri:SimpleFillSymbol>
  
  <esri:DrawTool id="drawTool"
        fillSymbol="{sfs}"
        graphicsLayer="{myGraphicsLayer}"
        lineSymbol="{sls}"
        map="{myMap}"
        markerSymbol="{sms}"/>
  <mx:NumberFormatter  id="numFormatter" 
        useThousandsSeparator="true" 
        precision="2"/>
  
  <mx:NumberFormatter  id="numFormatter2" 
        useThousandsSeparator="false" 
        precision="2"/>
  <esri:NavigationTool id="navTool" map="{myMap}" />
 </fx:Declarations>
 
 <s:controlBarLayout>
  <s:HorizontalLayout horizontalAlign="center"
       paddingBottom="7"
       paddingTop="7"/>
 </s:controlBarLayout>
 <s:controlBarContent>
  <s:ButtonBar id="bb" change="bb_changeHandler(event)">
   <s:ArrayList>
    <fx:String>Point</fx:String>
    <fx:String>Multipoint</fx:String>
    <fx:String>Single Line</fx:String>
    <fx:String>Polyline</fx:String>
    <fx:String>FreeHand Polyline</fx:String>
    <fx:String>Polygon</fx:String>
    <fx:String>Freehand Polygon</fx:String>
    <fx:String>Rectangle</fx:String>
   </s:ArrayList>
  </s:ButtonBar>
 </s:controlBarContent>
 
 <esri:Map id="myMap" level="3" useHandCursor="true">
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>
  <esri:GraphicsLayer id="myGraphicsLayer" creationComplete="init(event)"/>
 </esri:Map>
 
 <s:Label text="The DrawTool can be used to draw new features which can then either be used as input for another task or saved as new features in a feature service (using the FeatureLayer.applyEdits)" width="100%"/>
 
</s:Application>
0 Kudos
TonyCollins
Regular Contributor
Yes, I just finished playing and this issue happens 99% of the time in IE8 and IE7 as the example is going wrong for me now.

The issue does not seem to be there in Chrome, but my user base all use IE so that won't help me :o(
0 Kudos
DasaPaddock
Esri Regular Contributor
This seems to be a new Flash Player 10.1 bug that only happens in IE. If a custom cursor is being shown, and you right click, then the system cursor is supposed to be shown, but in FP 10.1 it isn't, so you're left with no cursors. This is happening for 1.x apps too.

I've submitted this bug to Adobe at https://bugs.adobe.com/jira/browse/SDK-26818

A workaround is to set the wmode to opaque, but only for IE since Chrome will show both cursors otherwise.

e.g. In the html template add this after params.allowfullscreen = "true";

if (swfobject.ua.ie && swfobject.ua.win) // http://code.google.com/p/swfobject/wiki/api
{
    params.wmode = "opaque"; // workaround for cursor issue - https://bugs.adobe.com/jira/browse/SDK-26818
}
0 Kudos