Пример #1
0
func iconPressCallback(menu *gtk3.Menu, entry *gtk3.Entry, position int, event gdk3.EventButton, data ...interface{}) {
	if position == gtk3.GtkEntryIconPosition.PRIMARY {
		menu.Popup(nil, nil, event.Button, event.Time, nil)
	} else {
		entry.SetText("")
	}
}
Пример #2
0
func entryPopulatePopup(entry *gtk3.Entry, menu *gtk3.Menu, data ...interface{}) {
	hasText := entry.GetTextLength() > 0

	item := gtk3.NewSeparatorMenuItem()
	item.Show()
	menu.Append(item)

	item2 := gtk3.NewMenuItemWithMnemonic("C_lear")
	item2.Show()
	item2.Connect("activate", func() { entry.SetText("") })
	menu.Append(item2)
	item2.SetSensitive(hasText)

	searchMenu := createSearchMenu(entry)
	item3 := gtk3.NewMenuItemWithLabel("Search by")
	item3.Show()
	item3.SetSubmenu(searchMenu)
	menu.Append(item3)
}