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 }
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() } } }
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() }) }
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 }
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 }
// 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 }
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) } }) }
func (e *TabbedEditor) Focus() { if e.SelectedPanel() != nil { gxui.SetFocus(e.SelectedPanel().(gxui.Focusable)) } }
func (e *Editor) Focus() { gxui.SetFocus(e.SelectedPanel().(gxui.Focusable)) }