Example #1
0
func (h *MyButtonHandler) HandleEvent(e gwu.Event) {
	if b, isButton := e.Src().(gwu.Button); isButton {
		b.SetText(b.Text() + h.text)
		h.counter++
		b.SetToolTip("You've clicked " + strconv.Itoa(h.counter) + " times!")
		e.MarkDirty(b)
	}
}
Example #2
0
func (h *MyButtonHandler) HandleEvent(e gwu.Event) {
	// Check if event source is a Button, just to be sure...
	// We add this handler to a button only, so this'll be always false.
	if b, isButton := e.Src().(gwu.Button); isButton {
		b.SetText(b.Text() + h.text)
		h.counter++
		b.SetToolTip("You've clicked " + strconv.Itoa(h.counter) + " times!")
		e.MarkDirty(b)
	}
}
Example #3
0
func (h *GreenHandler) HandleEvent(e gwu.Event) {
	var state bool
	src := e.Src()

	switch c := src.(type) {
	case gwu.CheckBox:
		state = c.State()
	case gwu.RadioButton:
		state = c.State()
	}

	if state {
		src.Style().SetBackground(gwu.CLR_GREEN)
	} else {
		src.Style().SetBackground("")
	}
	e.MarkDirty(src)
}