1. Anders Ruud
  2. love
  3. Issues


Issue #741 resolved

`newCursor` accepting a filepath / `setCursor` accepting a CursorType?

created an issue

I mentioned some of this on the forums but I thought I'd mention it here since I just thought of another reason why this might maybe perhaps be a good idea.

So currently, newCursor can accept an ImageData or a CursorType, and setCursor accepts a Cursor or nothing to reset to the default cursor.

I see two issues with this:

1: I'm not really sure how to phrase this, but it's weird that the constructor can only create one thing from the CursorType. Like...

cursor1 = love.mouse.newCursor('arrow')
cursor2 = love.mouse.newCursor('arrow')

2: Image cursors could be created from a filepath which could be nice, except since newCursor accepts a CursorType string the argument would be ambiguous.

cursor = love.mouse.newCursor('cursor.png')

So, how about...

1: setCursor could accept a Cursor or a CursorType.

2: love.mouse.newCursor could also accept a filepath.

I think it might make things nicer to use:

custom = love.mouse.newCursor(love.image.newImageData('cursor.png'))
arrow = love.mouse.newCursor('arrow')

if hover() then
custom = love.mouse.newCursor('cursor.png')

if hover() then

Comments (7)

  1. hahawoo reporter

    I guess so, but whatever it returns would still be a valid thing for setCursor to accept.

  2. Alex Szpakowski

    I still feel weird about setCursor accepting and getCursor returning two completely different variable types. Even the internal code for it would be pretty weird.

    Splitting newCursor into newImageCursor and newSystemCursor would allow for newImageCursor to accept a file path, at least. Perhaps getSystemCursor could be implemented instead of newSystemCursor.

  3. Log in to comment