app: [API] make ViewEvent an interface on all platforms

A uniform type allows convenient nil checks and for future window
backends on platforms other than Linux (which already had ViewEvent
as an interface).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-12-15 16:52:38 -06:00
parent 5e5d164929
commit f3fc0d62b8
7 changed files with 34 additions and 29 deletions
+4 -3
View File
@@ -25,7 +25,7 @@ import (
"gioui.org/unit"
)
type ViewEvent struct {
type JSViewEvent struct {
Element js.Value
}
@@ -114,7 +114,7 @@ func newWindow(win *callbacks, options []Option) {
w.Configure(options)
w.blur()
w.processEvent(ViewEvent{Element: cont})
w.processEvent(JSViewEvent{Element: cont})
w.processEvent(StageEvent{Stage: StageRunning})
w.resize()
w.draw(true)
@@ -830,4 +830,5 @@ func translateKey(k string) (key.Name, bool) {
return n, true
}
func (_ ViewEvent) ImplementsEvent() {}
func (JSViewEvent) implementsViewEvent() {}
func (JSViewEvent) ImplementsEvent() {}