Skip to content

Commit cc310c1

Browse files
author
jld3103
authored
Update mousecursor implementation (#449)
1 parent 51326a1 commit cc310c1

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

mousecursor.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package flutter
22

33
import (
4-
"errors"
54
"fmt"
65
"github.com/go-flutter-desktop/go-flutter/plugin"
76
"github.com/go-gl/glfw/v3.3/glfw"
@@ -37,24 +36,23 @@ func (p *mousecursorPlugin) handleActivateSystemCursor(arguments interface{}) (r
3736
p.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal)
3837
}
3938
switch kind := args["kind"]; {
40-
case kind == "none":
41-
case kind == "basic" || kind == "forbidden" || kind == "grab" || kind == "grabbing":
39+
case kind == "none" || kind == "basic":
40+
// nil cursor resets to standard arrow cursor
41+
case kind == "forbidden" || kind == "grab" || kind == "grabbing":
42+
// nil cursor resets to standard arrow cursor
4243
// go-gl GLFW currently (latest tagged v3.3 version) has no cursors for "forbidden", "grab" and "grabbing"
4344
// TODO: Wait for https://github.com/glfw/glfw/commit/7dbdd2e6a5f01d2a4b377a197618948617517b0e to appear in go-gl GLFW and implement the "forbidden" cursor
44-
cursor = glfw.CreateStandardCursor(glfw.ArrowCursor)
4545
case kind == "click":
4646
cursor = glfw.CreateStandardCursor(glfw.HandCursor)
4747
case kind == "text":
4848
cursor = glfw.CreateStandardCursor(glfw.IBeamCursor)
4949
default:
50-
return nil, errors.New(fmt.Sprintf("cursor kind %s not implemented", args["kind"]))
50+
return nil, fmt.Errorf("cursor kind %s not implemented", args["kind"])
5151
}
52+
p.window.SetCursor(cursor)
5253
if p.lastCursor != nil {
5354
p.lastCursor.Destroy()
5455
}
55-
if cursor != nil {
56-
p.window.SetCursor(cursor)
57-
p.lastCursor = cursor
58-
}
56+
p.lastCursor = cursor
5957
return nil, nil
6058
}

0 commit comments

Comments
 (0)