示例#1
0
文件: others.go 项目: sqp/godock
// 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")
	}
}
示例#2
0
文件: others.go 项目: sqp/godock
// 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)
	}
}
示例#3
0
func getText(entry *gtk.Entry) string {
	text, _ := entry.GetText()
	return text
}
示例#4
0
文件: others.go 项目: sqp/godock
// text changed by the user. Restore color and the ability to save the value.
func onTextDefaultChanged(entry *gtk.Entry, key *cftype.Key) {
	key.IsDefault = false
	context, _ := entry.GetStyleContext()
	context.RemoveClass("DefaultValue")
}