本文整理匯總了Golang中github.com/sqp/godock/widgets/cfbuild/cftype.Key.ValueSet方法的典型用法代碼示例。如果您正苦於以下問題:Golang Key.ValueSet方法的具體用法?Golang Key.ValueSet怎麽用?Golang Key.ValueSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/sqp/godock/widgets/cfbuild/cftype.Key
的用法示例。
在下文中一共展示了Key.ValueSet方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PackReset
// PackReset adds a reset value button.
//
func PackReset(key *cftype.Key, value interface{}) *gtk.Button {
fileDefault := key.Storage().FileDefault()
if fileDefault == "" {
return nil
}
back := newgtk.ButtonFromIconName("edit-clear", gtk.ICON_SIZE_MENU)
back.Connect("clicked", func() { key.ValueSet(value) })
key.PackSubWidget(back)
return back
}
示例2: TestValues
// TestValues updates the key data with test values.
//
func TestValues(key *cftype.Key) {
switch key.Type {
case cftype.KeyBoolButton,
cftype.KeyBoolCtrl:
if key.NbElements > 1 {
val := key.Value().ListBool()
newval := make([]bool, len(val))
for i, v := range val {
newval[i] = !v
}
key.ValueSet(newval)
} else {
val := key.Value().Bool()
newval := !val
key.ValueSet(newval)
}
case cftype.KeyIntSpin,
cftype.KeyIntSize,
cftype.KeyIntScale:
if key.NbElements > 1 {
val := key.Value().ListInt()
newval := make([]int, len(val))
for i, v := range val {
newval[i] = v + 1 + i
}
key.ValueSet(newval)
} else {
val := key.Value().Int()
newval := val + 1
key.ValueSet(newval)
}
case cftype.KeyFloatSpin,
cftype.KeyFloatScale:
if key.NbElements > 1 {
val := key.Value().ListFloat()
newval := make([]float64, len(val))
for i, v := range val {
newval[i] = v + 0.1 + float64(i) // hack +0.1 +i
}
key.ValueSet(newval)
} else {
val := key.Value().Float()
newval := val + 0.1
key.ValueSet(newval)
}
case cftype.KeyColorSelectorRGB,
cftype.KeyColorSelectorRGBA:
val := key.Value().ListFloat()
newval := make([]float64, len(val))
for i := range val {
newval[i] = val[i] + 0.1
if newval[i] > 1 {
newval[i]--
}
}
if len(newval) == 3 {
newval = append(newval, 1)
}
key.ValueSet(newval)
case cftype.KeyLink:
val := key.Value().String()
list := []string{urlDock, urlGoTour}
newval := cycleNextString(list, val, key)
key.ValueSet(newval)
case cftype.KeyStringEntry,
cftype.KeyFileSelector, cftype.KeyFolderSelector,
cftype.KeyImageSelector, cftype.KeySoundSelector,
cftype.KeyShortkeySelector, cftype.KeyClassSelector,
cftype.KeyPasswordEntry,
cftype.KeyListEntry:
val := key.Value().String()
newval := cycleNextString(otherStrings, val, nil)
key.ValueSet(newval)
case cftype.KeyFontSelector:
val := key.Value().String()
list := []string{"Arial 8", "Monospace 8"}
newval := cycleNextString(list, val, key)
key.ValueSet(newval)
case cftype.KeyTreeViewSortSimple,
cftype.KeyTreeViewSortModify:
val := key.Value().ListString()
newval := reverseStrings(val)
//.........這裏部分代碼省略.........