期望目标:写了个fyne的小工具,想要实现的操作是点击某个按钮后该按钮不可用,等处理完相关逻辑后再将按钮变为可用(包括其他的选择框也在点击按钮后不可用),同时在按钮不可用期间所有按键事件丢失
现状:在按钮的OnTapped时间中先将各个组件Disable(),处理完成后再调用Enable()。但发现点击后周四只是将相关组件置灰,暂时没去操作,带处理完按钮的处理时间后会处理按钮变亮前的操作(比如在置灰的状态下继续点了按钮,看起来当时没有响应,但待OnTapped方法执行完成调用Enable()方法后,还是处理了置灰状态的操作,只是延迟处理了)。相关代码
```
buildButton.OnTapped = func() {
if isInteTime() {
jobName := GetJobNameByGroupNameAndServiceName(groupSelect.Selected,projectSelect.Selected)
infoId := GetInfoIdByGroupNameAndServiceName(groupSelect.Selected,projectSelect.Selected)
fmt.Println("###################jobName:" + jobName + "infoId:" + infoId + "################")
//选择服务后操作
if jobName != "" && infoId != "" {
// fmt.Println("###################jobName:" + jobName + "infoId:" + infoId + "################")
//根据infoId得到jenkins信息
for _, groupJobInfo := range GroupJobInfos{
if groupJobInfo.InfoId == infoId {
//禁用按钮,选择
buildButton.Disable()
appSelect.Disable()
groupSelect.Disable()
projectSelect.Disable()
//执行构建
buildResult := utils.BuildJob(jobName,logLineEntry,groupJobInfo.JenkinsUrl,groupJobInfo.JenkinsUsername,groupJobInfo.JenkinsPassword)
//记录日志
writeLog(buildResult,projectSelect.Selected)
dialog.ShowInformation("提示",buildResult,win)
//启用按钮,选择
appSelect.Enable()
buildButton.Enable()
groupSelect.Enable()
projectSelect.Enable()
break
}
}
}else {
dialog.ShowInformation("提示","请选择构建的服务",win)
}
}else {
dialog.ShowInformation("提示","请非工作时间段使用",win)
}
}
```
有疑问加站长微信联系(非本文作者)