This is a migrated thread and some comments may be shown as answers.

How to Change Cursor of the Active Tool

1 Answer 118 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 23 Dec 2014, 12:48 PM
Hello,

I would like to know if we can change the cursor of the ActiveTool. In particular, when the TextTool is active I would like a different cursor to be displayed (currently it is the same as the PointerTool).  When the Pan Tool is set, the cursor does change, and all the tools derived from ToolBase class have a Cursor property, but it is protected.  Ideally, I'd like to be able to set the TextTool cursor in the XAML.  If there is a way to change the active cursor, what is the best approach?

Thanks in advance,

Mike

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 25 Dec 2014, 01:07 PM
Hi Mike,

When it comes to cursors RadDiagram works with the static DiagramCursors class that contains properties of type Cursor. As you noticed each tool expose a Cursor property, which is set to a property of the DiagramCursors class. Which means that if you replace the value (for example) of the DiagramCursors.Path property, the Cursor of the PathTool will be also changed. However, by design the TextTool does not need a special cursor and this is why it uses the default one for the application (the default arrow icon).
DiagramCursors.Panning = new Cursor("myCursor.cur"); // or whatever cursor you like

To achieve your requirement you can  change the cursor manually when the ActiveTool of the diagram is changed. For example when you set the ActiveTool to be a TextTool you can also set the Cursor property of the diagram. Then when the ActiveTool is changed back to PointerTool you can set the cursor back to the default pointer cursor.
//change active tool
this.diagram.ActiveTool = this.diagram.ActiveTool = MouseTool.PanTool;
this.diagram.Cursor = DiagramCursors.Panning;
 
//change the active back to pointer
this.diagram.ActiveTool = this.diagram.ActiveTool = MouseTool.PointerTool;
this.diagram.Cursor = DiagramCursors.Pointer;

Please let me know if this helps.

Regards,
Martin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Diagram
Asked by
Michael
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or