-
Notifications
You must be signed in to change notification settings - Fork 0
/
osevent.go
77 lines (57 loc) · 1.6 KB
/
osevent.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) 2021 The GoKi Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package osevent defines operating system level events, not associated
// with a particular window.
package osevent
import (
"fmt"
"image"
"github.com/goki/gi/oswin"
"github.com/goki/ki/kit"
)
// osevent.Event reports an OS level event
type Event struct {
oswin.EventBase
// Action taken on the osevent -- what has changed. Osevent state fields
// have current values.
Action Actions
}
// Actions is the action taken on the osevent by the user.
type Actions int32
const (
// OpenFiles means the user indicated that the app should open file(s) stored in Files
OpenFiles Actions = iota
ActionsN
)
//go:generate stringer -type=Actions
var KiT_Actions = kit.Enums.AddEnum(ActionsN, kit.NotBitFlag, nil)
/////////////////////////////
// oswin.Event interface
func (ev *Event) Type() oswin.EventType {
return oswin.OSEvent
}
func (ev *Event) HasPos() bool {
return false
}
func (ev *Event) Pos() image.Point {
return image.ZP
}
func (ev *Event) OnWinFocus() bool { // os events generally not focus-specific
return false
}
func (ev *Event) OnFocus() bool {
return false
}
func (ev *Event) String() string {
return fmt.Sprintf("Type: %v Action: %v Time: %v", ev.Type(), ev.Action, ev.Time())
}
// osevent.OpenFilesEvent is for OS open files action to open given files
type OpenFilesEvent struct {
Event
// Files are a list of files to open
Files []string
}
func (ev *OpenFilesEvent) Type() oswin.EventType {
return oswin.OSOpenFilesEvent
}