登录
首页 >  Golang >  Go问答

在 Fyne 中如何为 widget.Button 添加新的方法 ID?

来源:stackoverflow

时间:2024-02-23 20:54:17 291浏览 收藏

积累知识,胜过积蓄金银!毕竟在Golang开发的过程中,会遇到各种各样的问题,往往都是一些细节知识点还没有掌握好而导致的,因此基础知识点的积累是很重要的。下面本文《在 Fyne 中如何为 widget.Button 添加新的方法 ID?》,就带大家讲解一下知识点,若是你对本文感兴趣,或者是想搞懂其中某个知识点,就请你继续往下看吧~

问题内容

我这样做了,但没用

type buttonwithid struct {
    widget.listitemid
}

func newbuttonwithid(button widget.button) *buttonwithid {
    newbutton := &buttonwithid{}
    newbutton.extendbasewidget(newbutton)
    newbutton.listitemid = 0

    return newbutton
}

它返回此错误:

newButton.ExtendBaseWidget undefined (type *buttonWithID has no field or method ExtendBaseWidget)

解决方案


如果您想扩展 Button,那么您的结构必须嵌入 widget.Button 类型。下面将添加额外的字段。 教程见https://developer.fyne.io/tutorial/extending-widgets

到这里,我们也就讲完了《在 Fyne 中如何为 widget.Button 添加新的方法 ID?》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于的知识点!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>