Hide sketch mode popup for custom sketch tool

1069
2
Jump to solution
03-27-2020 08:09 AM
StephenRhea
New Contributor III

I have a custom polyline sketch tool that requires all segments to be line segments. However, I can't find a way to hide the "sketch mode" popup (shown below) to prevent the user from sketching curves. The best option I've found so far is to validate the geometry in OnSketchCompleteAsync and notify the user of any errors. Is there a way to hide this popup or, even better, to disable certain buttons for my tool?

Thanks,

Stephen

0 Kudos
1 Solution

Accepted Solutions
NarelleChedzey
Esri Contributor

Hi Stephan, 

You can definitely hide this toolbar or even replace it with your own toolbar. 

Look at the ContextToolbarID property on the MapTool class.  If you want to remove the toolbar, set this property to the empty string. 

public ConstructionTool1()
{
  IsSketchTool = true;
  UseSnapping = true;
  SketchType = SketchGeometryType.Line;
  UsesCurrentTemplate = true;
  ContextToolbarID = "";
  //ContextMenuID = "";
 }

You might want to also take a look at the ContextMenuID property which provides the right click context menu for sketching tools.  The default context menu has many similar options for sketching curves. 

If you want some of the tools to appear you can build your own toolbar in daml and then reference your toolbar damlId

Here is the default toolbar from the editing daml file that is used by sketching tools.  

<miniToolbar id="esri_editing_SegmentSketchContextToolbar">
 <row>
   <button refID="esri_editing_LineConstructor"/>
   <buttonPallete refID="esri_editing_LinePalette"/>
   <buttonPallete refID="esri_editing_ArcConstructorPalette"/>
   <button refID="esri_editing_TraceConstructorPalette"/>
   <button refID="esri_editing_StretchVertices" separator="true" />
   <button refID="esri_editing_FinishSketch" separator="true"/>
   <button refID="esri_editing_ClearSketch" />
 </row>
</miniToolbar>

You could build your own which references the first and last two buttons and then reference it in your tool constructor.  For example

<miniToolbar id="mySketchContextToolbar">
 <row>
   <button refID="esri_editing_LineConstructor"/>
   <button refID="esri_editing_FinishSketch" separator="true"/>
   <button refID="esri_editing_ClearSketch" />
 </row>
</miniToolbar>

public ConstructionTool1()
{
  IsSketchTool = true;
  UseSnapping = true;
  SketchType = SketchGeometryType.Line;
  UsesCurrentTemplate = true;
  ContextToolbarID = "mySketchContextToolbar";
  //ContextMenuID = "";
 }

Let me know if you have more questions. 

Regards

Narelle

View solution in original post

2 Replies
NarelleChedzey
Esri Contributor

Hi Stephan, 

You can definitely hide this toolbar or even replace it with your own toolbar. 

Look at the ContextToolbarID property on the MapTool class.  If you want to remove the toolbar, set this property to the empty string. 

public ConstructionTool1()
{
  IsSketchTool = true;
  UseSnapping = true;
  SketchType = SketchGeometryType.Line;
  UsesCurrentTemplate = true;
  ContextToolbarID = "";
  //ContextMenuID = "";
 }

You might want to also take a look at the ContextMenuID property which provides the right click context menu for sketching tools.  The default context menu has many similar options for sketching curves. 

If you want some of the tools to appear you can build your own toolbar in daml and then reference your toolbar damlId

Here is the default toolbar from the editing daml file that is used by sketching tools.  

<miniToolbar id="esri_editing_SegmentSketchContextToolbar">
 <row>
   <button refID="esri_editing_LineConstructor"/>
   <buttonPallete refID="esri_editing_LinePalette"/>
   <buttonPallete refID="esri_editing_ArcConstructorPalette"/>
   <button refID="esri_editing_TraceConstructorPalette"/>
   <button refID="esri_editing_StretchVertices" separator="true" />
   <button refID="esri_editing_FinishSketch" separator="true"/>
   <button refID="esri_editing_ClearSketch" />
 </row>
</miniToolbar>

You could build your own which references the first and last two buttons and then reference it in your tool constructor.  For example

<miniToolbar id="mySketchContextToolbar">
 <row>
   <button refID="esri_editing_LineConstructor"/>
   <button refID="esri_editing_FinishSketch" separator="true"/>
   <button refID="esri_editing_ClearSketch" />
 </row>
</miniToolbar>

public ConstructionTool1()
{
  IsSketchTool = true;
  UseSnapping = true;
  SketchType = SketchGeometryType.Line;
  UsesCurrentTemplate = true;
  ContextToolbarID = "mySketchContextToolbar";
  //ContextMenuID = "";
 }

Let me know if you have more questions. 

Regards

Narelle

StephenRhea
New Contributor III

That was exactly what I needed! Thanks, Narelle Chedzey!

0 Kudos