Example #1
0
func (ctrl *Control) Snapshot(request qml.Object) {
	if request.Int("status") != 2 {
		return
	}
	f, err := os.Create(os.Args[2])
	if err != nil {
		ctrl.done <- err
		return
	}
	defer f.Close()
	img := ctrl.win.Snapshot()
	err = png.Encode(f, img)
	if err != nil {
		os.Remove(os.Args[2])
	}
	ctrl.done <- err
}
Example #2
0
File: main.go Project: hbdlb/qml-1
func (ctrl *Control) TextReleased(text qml.Object) {
	x := text.Int("x")
	y := text.Int("y")
	width := text.Int("width")
	height := text.Int("height")

	ctrl.Emit(x+15, y+height/2)
	ctrl.Emit(x+width/2, 1.0*y+height/2)
	ctrl.Emit(x+width-15, 1.0*y+height/2)

	go func() {
		time.Sleep(500 * time.Millisecond)
		messages := []string{"Hello", "Hello", "Hacks"}
		ctrl.Message = messages[rand.Intn(len(messages))] + " from Go!"
		qml.Changed(ctrl, &ctrl.Message)
	}()
}
Example #3
0
File: main.go Project: hbdlb/qml-1
func (ctrl *Control) Done(emitter qml.Object) {
	emitter.Destroy()
}