"Add" Cursor

I know I can create this by making a @1x and @2x picture and MouseCursor function, and I will if necessary

But I was wondering if any one has a way to access a system generated one instead (macOS only for now)

Of course I am “assuming” that this is available from the OS :slight_smile:

https://documentation.xojo.com/index.php/Cursors

Is the Copy cursor what you’re looking for?

well, yes it is… thanks (the docs should show pictures :slight_smile: )

HOWEVER… while it works elsewhere in my app… it does NOT seem to work in Drag (as the LR says it should)

		d=New DragItem(Me,x,y,p.Width,p.Height,p)
		d.Text=Trim(ConvertEncoding(s,Encodings.UTF8))
		d.MouseCursor=system.cursors.copy // cursor remains "standard"
		d.drag

When I wanted something graphic, I used this approach

dim p as new picture (64, 64,32) p.graphics.drawpicture // whatever d.dragpicture = p

[quote=364540:@Jeff Tullin]When I wanted something graphic, I used this approach

dim p as new picture (64, 64,32) p.graphics.drawpicture // whatever d.dragpicture = p[/quote]
except I already have PICTURE §
I need to change the cursor that is dragging said picture

either its not being set… or something is resetting it

The mouse changes to that cursor automatically while you drag with the ALT button held. (Mac)
Thats the ‘move with copy’ signifier.

[quote=364547:@Jeff Tullin]The mouse changes to that cursor automatically while you drag with the ALT button held. (Mac)
Thats the ‘move with copy’ signifier.[/quote]
that does work… but not what I want… I don’t want the user to need to press a key just to change the cursor

the question goes back to a more basic one.

[per the LR]

DragItem.MouseCursor
Property (As MouseCursor)
aDragItem.MouseCursor = newMouseCursorValue
or
MouseCursorValue = aDragItem.MouseCursor
The cursor to be displayed during the drag.

Example

The following example displays a custom cursor for the drag. It is in the MouseDown event of the ImageWell.

Dim d as DragItem
d=New DragItem(Self, X,Y,Me.width,Me.height)

d.DragPicture=Keaton534
d.MouseCursor=system.Cursors.HandOpen
d.picture=Me.Image
d.Drag //Allow the drag

This is a long winded thread, but inside, Jim mcKay shared some techniques to use different cursors during drag. Could be useful for what you want to obtain.

https://forum.xojo.com/14202-drag-border-vs-focusring-visual-cues-and-drop-file-selected/

Seems based on my searching, that this basic question has been asked on and off since 2006 [ie… 11 years now]

The thing is, from what I remember, it worked very nicely.

[quote=364561:@Michel Bujardet]This is a long winded thread, but inside, Jim mcKay shared some techniques to use different cursors during drag. Could be useful for what you want to obtain.

https://forum.xojo.com/14202-drag-border-vs-focusring-visual-cues-and-drop-file-selected/[/quote]

YES!
from the post Michel mentioned {Thanks Jim McKay}

Function DragEnter(obj As DragItem, action As Integer) As Boolean
  Declare function NSClassFromString lib "Cocoa" (classname as CFStringRef) as ptr
  Declare Function dragCopyCursor lib "Cocoa" selector "dragCopyCursor" (cls as ptr) as ptr
  declare sub push lib "Cocoa" selector "push" (obj as ptr)
  
  push(dragCopyCursor(NSClassFromString("NSCursor")))
End Function
and

Sub DragExit(obj As DragItem, action As Integer)
  Declare function NSClassFromString lib "Cocoa" (classname as CFStringRef) as ptr
  Declare Function dragCopyCursor lib "Cocoa" selector "dragCopyCursor" (cls as ptr) as ptr
  declare sub pop lib "Cocoa" selector "pop" (obj as ptr)
  
  pop(dragCopyCursor(NSClassFromString("NSCursor")))
End Sub