app: add support for system cursors

Signed-off-by: pierre <pierre.curto@gmail.com>
This commit is contained in:
pierre
2020-12-02 16:50:56 +01:00
committed by Elias Naur
parent 951d45a2c6
commit 69cc2c795c
15 changed files with 297 additions and 18 deletions
+7 -1
View File
@@ -58,6 +58,7 @@ type window struct {
w Callbacks
stage system.Stage
displayLink *displayLink
cursor pointer.CursorName
scale float32
}
@@ -74,7 +75,7 @@ var launched = make(chan struct{})
// cascadeTopLeftFromPoint.
var nextTopLeft C.NSPoint
// mustView is like lookoupView, except that it panics
// mustView is like lookupView, except that it panics
// if the view isn't mapped.
func mustView(view C.CFTypeRef) *window {
w, ok := lookupView(view)
@@ -122,6 +123,10 @@ func (w *window) WriteClipboard(s string) {
})
}
func (w *window) SetCursor(name pointer.CursorName) {
w.cursor = windowSetCursor(w.cursor, name)
}
func (w *window) ShowTextInput(show bool) {}
func (w *window) SetAnimating(anim bool) {
@@ -227,6 +232,7 @@ func gio_onDraw(view C.CFTypeRef) {
func gio_onFocus(view C.CFTypeRef, focus C.BOOL) {
w := mustView(view)
w.w.Event(key.FocusEvent{Focus: focus == C.YES})
w.SetCursor(w.cursor)
}
//export gio_onChangeScreen