Beispiel #1
0
// got focus, removing default text if any.
func onTextDefaultFocusIn(widget *gtk.Entry, _ *gdk.Event, data textDefaultData) {
	if data.key.IsDefault {
		widget.HandlerBlock(data.cbID)
		widget.SetText("")
		widget.HandlerUnblock(data.cbID)
	}
}
Beispiel #2
0
// lost focus, setting back default text and color if needed.
func onTextDefaultFocusOut(widget *gtk.Entry, _ *gdk.Event, data textDefaultData) {
	text, _ := widget.GetText()
	data.key.IsDefault = text == ""
	if data.key.IsDefault {
		widget.HandlerBlock(data.cbID)
		widget.SetText(data.text)
		widget.HandlerUnblock(data.cbID)

		context, _ := widget.GetStyleContext()
		context.AddClass("DefaultValue")
	}
}