本文整理匯總了Golang中github.com/icza/gowut/gwu.Event.Src方法的典型用法代碼示例。如果您正苦於以下問題:Golang Event.Src方法的具體用法?Golang Event.Src怎麽用?Golang Event.Src使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/icza/gowut/gwu.Event
的用法示例。
在下文中一共展示了Event.Src方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: HandleEvent
func (h *MyButtonHandler) HandleEvent(e gwu.Event) {
if _, isButton := e.Src().(gwu.Button); isButton {
ioutil.WriteFile(
fmt.Sprintf("wikiPages/%s", fileName),
[]byte(wikiText), os.FileMode(os.O_WRONLY|os.O_CREATE|os.O_TRUNC|0777))
}
}
示例2: HandleEvent
func (h *MyButtonHandler) HandleEvent(e gwu.Event) {
if b, isButton := e.Src().(gwu.Button); isButton {
b.SetText(b.Text() + h.text)
h.counter++
b.SetToolTip("You've clicked " + strconv.Itoa(h.counter) + " times!")
e.MarkDirty(b)
}
}
示例3: HandleEvent
func (zz ExpanderHandler) HandleEvent(e gwu.Event) {
switch t := e.Src().(type) {
case gwu.Expander:
dir, _ := expanderDir[t]
//fmt.Println("Dir=" + dir)
files, _ := ioutil.ReadDir(dir)
var p gwu.Panel
var table gwu.Table
p = nil
dirList := make([]gwu.Comp, 0, 0)
fileLabelList := make([]gwu.Comp, 0, 0)
fileTimeList := make([]gwu.Comp, 0, 0)
fileSizeList := make([]gwu.Comp, 0, 0)
for _, f := range files {
if p == nil {
p = gwu.NewPanel()
t.SetContent(p)
table = gwu.NewTable()
table.SetCellPadding(5)
p.Add(table)
}
if f.IsDir() {
// owned by root // only works on linux
newExpander := makeExpander(f.Name())
newExpander.SetToolTip("DIR - Click to view contents")
newExpander.Style().SetColor("blue")
if dir == "/" {
expanderDir[newExpander] = dir + f.Name()
} else {
expanderDir[newExpander] = dir + "/" + f.Name()
}
newExpander.AddEHandler(handler, gwu.ETYPE_STATE_CHANGE)
dirList = append(dirList, newExpander)
} else {
fileLabel := gwu.NewLabel(f.Name())
fileLabel.Style().SetPaddingLeft("20")
fileLabel.SetToolTip("FILE")
fileLabel.AddEHandler(foobar, gwu.ETYPE_MOUSE_DOWN)
fileLabelList = append(fileLabelList, fileLabel)
fileTimeLabel := gwu.NewLabel(f.ModTime().Format(layout))
fileTimeList = append(fileTimeList, fileTimeLabel)
fileSizeLabel := gwu.NewLabel(strconv.FormatInt(f.Size(), 10) + "k")
fileSizeList = append(fileSizeList, fileSizeLabel)
}
}
row := 0
for _, dir := range dirList {
table.Add(dir, row, 0)
row = row + 1
}
for i, _ := range fileLabelList {
table.Add(fileLabelList[i], row, 0)
rfmt := table.CellFmt(row, 0)
rfmt.SetHAlign(gwu.HA_LEFT)
rfmt.SetVAlign(gwu.VA_TOP)
table.Add(fileTimeList[i], row, 1)
rfmt = table.CellFmt(row, 1)
rfmt.SetHAlign(gwu.HA_LEFT)
rfmt.SetVAlign(gwu.VA_TOP)
table.Add(fileSizeList[i], row, 2)
rfmt = table.CellFmt(row, 2)
rfmt.SetHAlign(gwu.HA_RIGHT)
rfmt.SetVAlign(gwu.VA_TOP)
row = row + 1
}
default:
// t is some other type that we didn't name.
}
}