我在文档中使用软件包golang.org/x/exp/shiny/screen
,它说创建屏幕的基本用法是:
func main() {
driver.Main(func(s screen.Screen) {
w, err := s.NewWindow(nil)
if err != nil {
handleError(err)
return
}
defer w.Release()
for {
switch e := w.NextEvent().(type) {
case lifecycle.Event:
if e.To == lifecycle.StageDead {
return
}
etc
case etc:
etc
}
}
})
}
如何获取屏幕的位置?
从定义上说,该结构由
组成type NewWindowOptions struct {
// Width and Height specify the dimensions of the new window. If Width
// or Height are zero, a driver-dependent default will be used for each
// zero value dimension.
Width, Height int
// Title specifies the window title.
Title string
}
所以我当时想得到Width
和Height
答案 0 :(得分:0)
根据您要实现的目标,我假设您可以重用示例https://github.com/golang/exp/blob/master/shiny/example/basic/main.go
中的某些部分以下是您可能感兴趣的摘录:
var sz size.Event
for {
e := w.NextEvent()
switch e := e.(type) {
//...
// Basically wait for the resize event...
case size.Event:
// Save the latest size so later you could read it as sz.Bounds()
sz = e
// ...
}
...
sz.Bounds()
返回:https://godoc.org/image#Rectangle,希望它的Min
,Max
点是绝对位置。