本文整理汇总了Golang中github.com/js-arias/sparta.Widget.Update方法的典型用法代码示例。如果您正苦于以下问题:Golang Widget.Update方法的具体用法?Golang Widget.Update怎么用?Golang Widget.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/js-arias/sparta.Widget
的用法示例。
在下文中一共展示了Widget.Update方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: trViewInitTree
func trViewInitTree(m, tv sparta.Widget) {
d := m.Property(sparta.Data).(*trList)
if d.pos >= len(d.phyLs) {
return
}
title := fmt.Sprintf("%s: %s [id: %s]", cmd.Name, d.phyLs[d.pos].Name, d.phyLs[d.pos].Id)
m.SetProperty(sparta.Caption, title)
rect := tv.Property(sparta.Geometry).(image.Rectangle)
curTree := setTree(d.phyLs[d.pos], rect)
curTree.putOnScreen()
tv.SetProperty(sparta.Data, curTree)
tv.Update()
}
示例2: txKey
// TxKey gets keyboard events.
func txKey(tx sparta.Widget, e interface{}) bool {
data := tx.Property(sparta.Data).(*pageData)
ev := e.(sparta.KeyEvent)
switch ev.Key {
case sparta.KeyDown:
if (data.pos + 1) < (len(poem) - data.page + 1) {
data.pos++
}
tx.Update()
case sparta.KeyUp:
if (data.pos - 1) >= 0 {
data.pos--
}
tx.Update()
case sparta.KeyPageUp:
if data.pos == 0 {
break
}
data.pos -= data.page
if data.pos < 0 {
data.pos = 0
}
tx.Update()
case sparta.KeyPageDown:
if data.pos == (len(poem) - data.page) {
break
}
data.pos += data.page
if data.pos > (len(poem) - data.page + 1) {
data.pos = len(poem) - data.page
}
tx.Update()
}
return true
}
示例3: txNavInfo
func txNavInfo(tx sparta.Widget, data *txList) {
if len(data.sels) == 0 {
tx.SetProperty(sparta.Data, nil)
} else {
pair := &txTaxAnc{
tax: data.desc[data.sels[0]],
anc: data.tax,
}
if data.tax.Id == "0" {
pair.anc = nil
}
tx.SetProperty(sparta.Data, pair)
}
tx.Update()
}
示例4: trViewMouse
func trViewMouse(tv sparta.Widget, e interface{}) bool {
dt := tv.Property(sparta.Data)
if dt == nil {
return true
}
data := dt.(*trData)
ev := e.(sparta.MouseEvent)
switch ev.Button {
case sparta.MouseRight:
if !setFlag {
return true
}
if data.sel == nil {
return true
}
sel := trViewNearestNode(ev.Loc, data.node)
if sel == nil {
return true
}
x, y, pos := data.x, data.y, data.pos
p := tv.Property(sparta.Parent).(sparta.Widget)
d := p.Property(sparta.Data).(*trList)
if sel == data.sel {
vals := new(jdh.Values)
vals.Add(jdh.NodCollapse, sel.id)
localDB.Exec(jdh.Delete, jdh.Nodes, vals)
localDB.Exec(jdh.Commit, "", nil)
} else if !sel.isValidSis(data.sel) {
return true
} else {
vals := new(jdh.Values)
vals.Add(jdh.KeyId, data.sel.id)
vals.Add(jdh.NodSister, sel.id)
localDB.Exec(jdh.Set, jdh.Nodes, vals)
localDB.Exec(jdh.Commit, "", nil)
}
rect := tv.Property(sparta.Geometry).(image.Rectangle)
data = setTree(d.phyLs[d.pos], rect)
data.x, data.y, data.pos = x, y, pos
tv.SetProperty(sparta.Data, data)
data.putOnScreen()
tv.Update()
case sparta.MouseLeft:
data.sel = trViewNearestNode(ev.Loc, data.node)
tv.Update()
case -sparta.MouseWheel:
data.pos.Y -= 5
data.putOnScreen()
tv.Update()
case sparta.MouseWheel:
data.pos.Y += 5
data.putOnScreen()
tv.Update()
}
return true
}
示例5: txMouse
// TxMouse gets mouse events.
func txMouse(tx sparta.Widget, e interface{}) bool {
data := tx.Property(sparta.Data).(*pageData)
ev := e.(sparta.MouseEvent)
switch ev.Button {
case sparta.MouseLeft, -sparta.MouseWheel:
if (data.pos + 1) < (len(poem) - data.page + 1) {
data.pos++
}
tx.Update()
case sparta.MouseRight, sparta.MouseWheel:
if (data.pos - 1) >= 0 {
data.pos--
}
tx.Update()
}
return true
}
示例6: spNavInfo
func spNavInfo(tx sparta.Widget, db jdh.DB, spe *jdh.Specimen, tax *jdh.Taxon) {
if spe == nil {
tx.SetProperty(sparta.Data, nil)
tx.Update()
return
}
if spe.Taxon != tax.Id {
tx.SetProperty(sparta.Data, nil)
tx.Update()
return
}
info := &spInfo{
tax: tax,
spe: spe,
}
if len(spe.Dataset) > 0 {
info.set = dataset(cmd, db, spe.Dataset)
}
tx.SetProperty(sparta.Data, info)
tx.Update()
}
示例7: trViewKey
func trViewKey(tv sparta.Widget, e interface{}) bool {
dt := tv.Property(sparta.Data)
if dt == nil {
return true
}
data := dt.(*trData)
rect := tv.Property(sparta.Geometry).(image.Rectangle)
ev := e.(sparta.KeyEvent)
switch ev.Key {
case sparta.KeyDown:
data.pos.Y -= 5
case sparta.KeyUp:
data.pos.Y += 5
case sparta.KeyLeft:
data.pos.X -= 5
case sparta.KeyRight:
data.pos.X += 5
case sparta.KeyHome:
data.pos = image.Pt(0, 0)
case sparta.KeyPageUp:
data.pos.Y += rect.Dy() - sparta.HeightUnit
case sparta.KeyPageDown:
data.pos.Y -= rect.Dy() - sparta.HeightUnit
case ' ', sparta.KeyReturn:
p := tv.Property(sparta.Parent).(sparta.Widget)
d := p.Property(sparta.Data).(*trList)
if (d.pos + 1) >= len(d.phyLs) {
return false
}
d.pos++
title := fmt.Sprintf("%s: please wait", cmd.Name)
p.SetProperty(sparta.Caption, title)
tv.SetProperty(sparta.Data, nil)
go trViewInitTree(p, tv)
case sparta.KeyBackSpace:
p := tv.Property(sparta.Parent).(sparta.Widget)
d := p.Property(sparta.Data).(*trList)
if (d.pos - 1) < 0 {
return false
}
d.pos--
tv.SetProperty(sparta.Data, nil)
title := fmt.Sprintf("%s: please wait", cmd.Name)
p.SetProperty(sparta.Caption, title)
go trViewInitTree(p, tv)
case '+':
data.y = data.y * 5 / 4
case '-':
data.y = data.y * 4 / 5
case '*':
data.x = data.x * 5 / 4
case '/':
data.x = data.x * 4 / 5
case '#':
root := data.node[0]
data.y = float32(rect.Dy()-10) / float32(root.terms+2)
data.x = float32(rect.Dx()-10-(sparta.WidthUnit*32)) / float32(root.level)
case '=':
data.y = float32(sparta.HeightUnit)
data.x = float32(sparta.WidthUnit * 2)
case '>':
if !data.aln {
return false
}
data.aln = false
case '<':
if data.aln {
return false
}
data.aln = true
default:
return true
}
data.putOnScreen()
tv.Update()
return false
}