示例#1
0
func (b *commandBox) nextInput() (more bool) {
	next := b.current.Next()
	if next == nil {
		return false
	}
	b.clearInput()
	b.input = next
	b.AddChild(b.input)
	gxui.SetFocus(b.input)
	return true
}
示例#2
0
func (l *DropDownList) HideList() {
	if l.listShowing {
		l.listShowing = false
		l.overlay.Hide()
		if l.Attached() {
			gxui.SetFocus(l)
		}
		if l.onHideList != nil {
			l.onHideList.Fire()
		}
	}
}
示例#3
0
文件: menu.go 项目: nelsam/vidar
func (m *menu) Add(command Command, bindings ...gxui.KeyboardEvent) {
	item := newMenuItem(m.theme, command.Name(), bindings...)
	m.AddChild(item)
	item.OnClick(func(gxui.MouseEvent) {
		if m.commander.box.Run(command) {
			gxui.SetFocus(m.commander.box.input)
			return
		}
		if executor, ok := command.(Executor); ok {
			m.commander.Controller().Execute(executor)
		}
		m.commander.box.Finish()
	})
}
示例#4
0
func (l *DropDownList) ShowList() bool {
	if l.listShowing || l.overlay == nil {
		return false
	}
	l.listShowing = true
	s := l.Size()
	at := math.Point{X: s.W / 2, Y: s.H}
	l.overlay.Show(l.list, gxui.TransformCoordinate(at, l.outer, l.overlay))
	gxui.SetFocus(l.list)
	if l.onShowList != nil {
		l.onShowList.Fire()
	}
	return true
}
示例#5
0
func (b *commandBox) nextInput() (more bool) {
	queue, ok := b.current.(InputQueue)
	if !ok {
		return false
	}
	next := queue.Next()
	if next == nil {
		return false
	}
	b.clearInput()
	b.input = next
	b.AddChild(b.input)
	gxui.SetFocus(b.input)
	return true
}
示例#6
0
文件: main.go 项目: nelsam/gxui
// Create implements gxui.TreeNode.
func (n *node) Create(theme gxui.Theme) gxui.Control {
	layout := theme.CreateLinearLayout()
	layout.SetDirection(gxui.LeftToRight)

	label := theme.CreateLabel()
	label.SetText(n.name)

	textbox := theme.CreateTextBox()
	textbox.SetText(n.name)
	textbox.SetPadding(math.ZeroSpacing)
	textbox.SetMargin(math.ZeroSpacing)

	addButton := theme.CreateButton()
	addButton.SetText("+")
	addButton.OnClick(func(gxui.MouseEvent) { n.add("<new>") })

	edit := func() {
		layout.RemoveAll()
		layout.AddChild(textbox)
		layout.AddChild(addButton)
		gxui.SetFocus(textbox)
	}

	commit := func() {
		n.name = textbox.Text()
		label.SetText(n.name)
		layout.RemoveAll()
		layout.AddChild(label)
		layout.AddChild(addButton)
	}

	// When the user clicks the label, replace it with an editable text-box
	label.OnClick(func(gxui.MouseEvent) { edit() })

	// When the text-box loses focus, replace it with a label again.
	textbox.OnLostFocus(commit)

	layout.AddChild(label)
	layout.AddChild(addButton)
	return layout
}
示例#7
0
文件: menu.go 项目: nelsam/vidar
func (b *menuButton) SetMenu(boundser Boundser, menu *menu) {
	b.OnClick(func(gxui.MouseEvent) {
		if b.menuParent.Children().IndexOf(menu) >= 0 {
			b.menuParent.RemoveChild(menu)
			return
		}
		bounds := boundser.Bounds()
		child := b.menuParent.AddChild(menu)
		offset := math.Point{
			X: bounds.Min.X,
			Y: bounds.Max.Y,
		}
		child.Offset = offset
		gxui.SetFocus(menu)
	})
	menu.OnLostFocus(func() {
		if b.menuParent.Children().IndexOf(menu) >= 0 {
			b.menuParent.RemoveChild(menu)
		}
	})
}
示例#8
0
func (e *TabbedEditor) Focus() {
	if e.SelectedPanel() != nil {
		gxui.SetFocus(e.SelectedPanel().(gxui.Focusable))
	}
}
示例#9
0
func (e *Editor) Focus() {
	gxui.SetFocus(e.SelectedPanel().(gxui.Focusable))
}