Community
Participate
Working Groups
I'm trying to customize default cursor for Canvas with Canvas.setCursor() method. Unfortunately, it doesn't work well. At the time the view is opened the cursor looks good - the one I specified. But when I move mouse over selection handle and then move it back to canvas, the cursor changes to default arrow, and doesn't seem to change to my custom cursor ever after that.
Have you tried setting the default cursor -- setDefaultCursor() -- for the tool?
It doesn't work for the selection tool.
Does this get addressed in near future? It is a real problem not to get a dragtrackers cursor if a tool's default cursor has been set. Use case: I have a specialized selection tool with a cursor which depicts the selection tolerance with a circle. By using this special cursor I do not get my dragtrackers cursor.
I don't even understand my own comment. Did you try setDefaultCursor() on the selection tool? You can also set cursors on figures, such as the contents editpart's figure. That would probably work best, since handles' cursors are shown via draw2d cursor support.
The selectiontool has a custom cursor which is set with setDefaultCursor(). This works fine. On the handles (class VertexHandle extends SquareHandle) I put another cursor. In the constructor I call super(owner, locator, Cursors.SIZEALL); This does *not* give me a SIZEALL cursor when the cursor is over a handle. In VertexHandle.createDragTracker I return a VertexTracker. Only when a VertexTracker (extends SimpleDragTracker) is actually dragging such a handle, the cursor becomes SIZEALL. It does not make any difference if I call setDefaultCursor(Cursors.SIZEALL) in the VertexTracker. I think the problem is demonstrated by the following stackdump: Thread [main] (Suspended) DomainEventDispatcher(SWTEventDispatcher).setCursor(Cursor) line: 418 DomainEventDispatcher.setCursor(Cursor) line: 473 => DomainEventDispatcher.setOverrideCursor(Cursor) line: 495 SpatialEditor$1MyViewer(GraphicalViewerImpl).setCursor(Cursor) line: 316 SelTool(AbstractTool).setCursor(Cursor) line: 1214 SelTool(AbstractTool).refreshCursor() line: 1166 SelTool(SelectionTool).refreshCursor() line: 569 SelTool(AbstractTool).setViewer(EditPartViewer) line: 1335 SelTool(AbstractTool).focusGained(FocusEvent, EditPartViewer) line: 411 EditDomain.focusGained(FocusEvent, EditPartViewer) line: 84 DomainEventDispatcher.dispatchFocusGained(FocusEvent) line: 224 LightweightSystem$EventHandler.focusGained(FocusEvent) line: 348 TypedListener.handleEvent(Event) line: 105 EventTable.sendEvent(Event) line: 66 FigureCanvas(Widget).sendEvent(Event) line: 925 at => the DomainEventDispatchers overrideCursor is set. If set, this overrideCursor is used instead of any other cursor. In this case the default cursor of the tool takes precedence over the cursor of any figure in the drawing. Only when another tool (such as the VertexTracker) becomdes active, another cursor gets a chance (be it the cursor of the VertexHandle, or the default cursor of the VertexTracker). I suppose there are use cases for behaviour like the displayed behaviour. It is difficult to make a general statement about which cursor is more important and should be displayed: a. the cursor of a general tool (such as the selection tool) or b. the cursor of a more specialized tool which can become active over a certain figure (such as the VertexTracker at a VertexHandle) Randy, what would you advise in this case?
I think my original comment is starting to make sense to me now. You can't change the Selection tool's default cursor because GEF's active tool's cursor overrides any figure cursor from draw2d. So, how do you set a tool's cursor and make it lower priority than any figure cursor? You can't, so just try to set the root figure's cursor instead or something like that.
This seems plausible, and to a certain degree it works. But, when the cursor is over a figure which is not the rootfigure the cursor changes back to its system default (the arrow) ...
To understand this better we may need to answer the following question: What is a cursor used for, what does it tell us? 1. does it tell us something about the state of an object 2. does it tell us something about what can be done with the object 3. does it tell is something about what we are doing now with the object 4. ... ad 1. This what what IFigure.setCursor() seems to intend to do. ad 2. This may be more than one action, depending on for example modifier keys. What action is choosen, what tool is going to be used, is not known at forehand. ad 3. Is a little bit late, not quite informative.