Bug in Edit?

2310
8
Jump to solution
06-30-2014 10:04 AM
TimWitt
Frequent Contributor
Hey everybody,

I have recently created a Draw App that uses Edit, to be able to edit graphics and text.

It can be found here: http://jsfiddle.net/timw1984/T27G4/

When I do the following steps there seems to be a problem though.

1) Write some text in the textbox on the right -> right-click the map and click on "Add Text"
2) Now right-click the text and choose "Edit"
3) This pops up a menu in which you can change color/Alignment or double-click the text and change what it says.

Once done I should be able to click the map and the menu should disappear, but it doesn't. I am using EDIT_TEXT constant to do this.

The weird part is, when I choose "Rotate/Scale" (which uses the SCALE constant) instead of "Edit", the same menu pops-up and now when I click on the map the menu disappears.

Am I doing something wrong or could this be a bug?

Tim
0 Kudos
1 Solution

Accepted Solutions
MatthewLofgren
Occasional Contributor
Looking at the error, it looks like Text editing (maybe all points) requires Edit.EDIT_VERTICES, Edit.EDIT_TEXT (text only?), Edit.MOVE tools

n=this._enableBoxEditing(b,c,p);(a&e)===e&&(k=this._enableVertexEditing(b));(a&g)===g&&this._enableTextEditing(b);if(!h&&!k&&!n)throw Error("[esri.toolbars.Edit::activate] Unable to activate the tool. Check if the tool is valid for the given geometry type.");

The code below prevents the error, which makes the popup work as expected....

function createGraphicsMenu() {       // Creates right-click context menu for GRAPHICS       ctxMenuForGraphics = new Menu({});       ctxMenuForGraphics.addChild(new MenuItem({          label: "Edit",         onClick: function() {           if ( selected.geometry.type !== "point" ) {           editToolbar.activate(Edit.EDIT_VERTICES, selected);           } else {             editToolbar.activate(Edit.MOVE | Edit.EDIT_VERTICES | Edit.EDIT_TEXT, selected);           }         }        }));

View solution in original post

0 Kudos
8 Replies
JeffPace
MVP Regular Contributor
i am getting

Uncaught Error: [esri.toolbars.Edit::activate] Unable to activate the tool. Check if the tool is valid for the given geometry type. edit.js:22
w.activate edit.js:22
ctxMenuForGraphics.addChild.MenuItem.onClick (index):118
k.onItemClick _MenuBase.js:8
(anonymous function) _MenuBase.js:4
(anonymous function)
0 Kudos
JeffPace
MVP Regular Contributor
odd. ok it is coming back as a point.  Which is good.  You are setting the point with a textsymbol properly.

however when you pass that to
editToolbar.activate(Edit.EDIT_TEXT, selected);

i get the
[esri.toolbars.Edit::activate] Unable to activate the tool. Check if the tool is valid for the given geometry type.
Which is why you cant close it, because it wasnt properly created.

What I can't figure out is, why not? it looks like everything is fine.
0 Kudos
TimWitt
Frequent Contributor
Hey Jeff,

thanks for checking it out.

I know, its a headscratcher, especially since all the functions of the "Edit" tool work properly (you can change alignment and change the color of the text) it just doesn't close.

Tim
0 Kudos
JeffPace
MVP Regular Contributor
as much as you can sniff an obfuscated API, it looks like your point is failing the _IsTextSymbol internal check of edit.js
0 Kudos
TimWitt
Frequent Contributor
I wonder if anyone has a working example that lets text be edited, I just don't see why it shouldn't work.

Nevermind I found a working example here.

The difference here is that they declare a point first to get the location of the text, I feed it the location directly. Could that cause the issue? If so, how would I solve that problem?
0 Kudos
MatthewLofgren
Occasional Contributor
Looking at the error, it looks like Text editing (maybe all points) requires Edit.EDIT_VERTICES, Edit.EDIT_TEXT (text only?), Edit.MOVE tools

n=this._enableBoxEditing(b,c,p);(a&e)===e&&(k=this._enableVertexEditing(b));(a&g)===g&&this._enableTextEditing(b);if(!h&&!k&&!n)throw Error("[esri.toolbars.Edit::activate] Unable to activate the tool. Check if the tool is valid for the given geometry type.");

The code below prevents the error, which makes the popup work as expected....

function createGraphicsMenu() {       // Creates right-click context menu for GRAPHICS       ctxMenuForGraphics = new Menu({});       ctxMenuForGraphics.addChild(new MenuItem({          label: "Edit",         onClick: function() {           if ( selected.geometry.type !== "point" ) {           editToolbar.activate(Edit.EDIT_VERTICES, selected);           } else {             editToolbar.activate(Edit.MOVE | Edit.EDIT_VERTICES | Edit.EDIT_TEXT, selected);           }         }        }));
0 Kudos
JeffPace
MVP Regular Contributor
Looking at the error, it looks like Text editing (maybe all points) requires Edit.EDIT_VERTICES, Edit.EDIT_TEXT (text only?), Edit.MOVE tools

n=this._enableBoxEditing(b,c,p);(a&e)===e&&(k=this._enableVertexEditing(b));(a&g)===g&&this._enableTextEditing(b);if(!h&&!k&&!n)throw Error("[esri.toolbars.Edit::activate] Unable to activate the tool. Check if the tool is valid for the given geometry type.");

The code below prevents the error, which makes the popup work as expected....

function createGraphicsMenu() {
      // Creates right-click context menu for GRAPHICS
      ctxMenuForGraphics = new Menu({});
      ctxMenuForGraphics.addChild(new MenuItem({ 
        label: "Edit",
        onClick: function() {
          if ( selected.geometry.type !== "point" ) {
          editToolbar.activate(Edit.EDIT_VERTICES, selected);
          } else {
            editToolbar.activate(Edit.MOVE | Edit.EDIT_VERTICES | Edit.EDIT_TEXT, selected);
          }
        } 
      }));


nicely done.  I got to there in the code, but couldnt get the solution out.  excellent
0 Kudos
TimWitt
Frequent Contributor
Matt,

great job! I still wonder if this is a bug maybe?

Thanks anyways!

Tim
0 Kudos