-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcursor.go
49 lines (37 loc) · 857 Bytes
/
cursor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package saver
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/driver"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/widget"
)
func hideCursor(w fyne.Window) {
if native, ok := w.(driver.NativeWindow); ok {
native.RunNative(func(ctx any) {
doHideCursor(w, ctx)
})
}
}
func showCursor(w fyne.Window) {
if native, ok := w.(driver.NativeWindow); ok {
native.RunNative(func(ctx any) {
doShowCursor(w, ctx)
})
}
}
type cursorCapture struct {
widget.BaseWidget
moved func()
}
func (c *cursorCapture) CreateRenderer() fyne.WidgetRenderer {
return widget.NewSimpleRenderer(canvas.NewRectangle(color.Transparent))
}
func (c *cursorCapture) MouseIn(ev *desktop.MouseEvent) {
}
func (c *cursorCapture) MouseMoved(ev *desktop.MouseEvent) {
c.moved()
}
func (c *cursorCapture) MouseOut() {
}