本文整理汇总了Golang中github.com/lxn/walk.Dialog.SetDefaultButton方法的典型用法代码示例。如果您正苦于以下问题:Golang Dialog.SetDefaultButton方法的具体用法?Golang Dialog.SetDefaultButton怎么用?Golang Dialog.SetDefaultButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/lxn/walk.Dialog
的用法示例。
在下文中一共展示了Dialog.SetDefaultButton方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Create
func (d Dialog) Create(owner walk.Form) error {
var w *walk.Dialog
var err error
if d.FixedSize {
w, err = walk.NewDialogWithFixedSize(owner)
} else {
w, err = walk.NewDialog(owner)
}
if err != nil {
return err
}
tlwi := topLevelWindowInfo{
Name: d.Name,
Font: d.Font,
ToolTipText: "",
MinSize: d.MinSize,
MaxSize: d.MaxSize,
ContextMenuItems: d.ContextMenuItems,
DataBinder: d.DataBinder,
Layout: d.Layout,
Children: d.Children,
OnKeyDown: d.OnKeyDown,
OnKeyPress: d.OnKeyPress,
OnKeyUp: d.OnKeyUp,
OnMouseDown: d.OnMouseDown,
OnMouseMove: d.OnMouseMove,
OnMouseUp: d.OnMouseUp,
OnSizeChanged: d.OnSizeChanged,
}
var db *walk.DataBinder
if d.DataBinder.AssignTo == nil {
d.DataBinder.AssignTo = &db
}
builder := NewBuilder(nil)
w.SetSuspended(true)
builder.Defer(func() error {
w.SetSuspended(false)
return nil
})
return builder.InitWidget(tlwi, w, func() error {
if err := w.SetTitle(d.Title); err != nil {
return err
}
if err := w.SetSize(d.Size.toW()); err != nil {
return err
}
if d.DefaultButton != nil {
if err := w.SetDefaultButton(*d.DefaultButton); err != nil {
return err
}
if db := *d.DataBinder.AssignTo; db != nil {
if db.DataSource() != nil {
(*d.DefaultButton).SetEnabled(db.CanSubmit())
}
db.CanSubmitChanged().Attach(func() {
(*d.DefaultButton).SetEnabled(db.CanSubmit())
})
}
}
if d.CancelButton != nil {
if err := w.SetCancelButton(*d.CancelButton); err != nil {
return err
}
}
if d.AssignTo != nil {
*d.AssignTo = w
}
return nil
})
}