本文整理匯總了Golang中github.com/nelsam/gxui.Theme.CreateTextBox方法的典型用法代碼示例。如果您正苦於以下問題:Golang Theme.CreateTextBox方法的具體用法?Golang Theme.CreateTextBox怎麽用?Golang Theme.CreateTextBox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/nelsam/gxui.Theme
的用法示例。
在下文中一共展示了Theme.CreateTextBox方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewProjectOpener
func NewProjectOpener(theme gxui.Theme, projPane gxui.Control) *ProjectOpener {
return &ProjectOpener{
statusKeeper: statusKeeper{theme: theme},
name: theme.CreateTextBox(),
projPane: projPane,
}
}
示例2: NewGotoLine
func NewGotoLine(theme gxui.Theme) *GotoLine {
input := theme.CreateTextBox()
input.OnTextChanged(func([]gxui.TextBoxEdit) {
runes := []rune(input.Text())
for index := 0; index < len(runes); index++ {
if !unicode.IsDigit(runes[index]) {
runes = append(runes[:index], runes[index+1:]...)
index--
}
}
text := string(runes)
if text != input.Text() {
input.SetText(text)
}
})
return &GotoLine{
statusKeeper: statusKeeper{theme: theme},
lineNumInput: input,
}
}
示例3: Create
// 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
}