forked from joejulian/gio
widget: [API] move Clickable state update from Layout to Clicks
Before this change, Clickable state updates would happen in Layout. However, that is too late in cases where clicks affects layout that contiains the Clickable. This change removes state changes from Layout and moves them to Clicks, to allow users pre-layout access. Note that Layout itself processes events, which means users can no longer access clicks after Layout. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+4
-4
@@ -43,11 +43,11 @@ func (b *Bool) History() []Press {
|
||||
}
|
||||
|
||||
func (b *Bool) Layout(gtx layout.Context, w layout.Widget) layout.Dimensions {
|
||||
for b.clk.Clicked(gtx) {
|
||||
b.Value = !b.Value
|
||||
b.changed = true
|
||||
}
|
||||
dims := b.clk.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
for b.clk.Clicked() {
|
||||
b.Value = !b.Value
|
||||
b.changed = true
|
||||
}
|
||||
semantic.SelectedOp(b.Value).Add(gtx.Ops)
|
||||
semantic.EnabledOp(gtx.Queue != nil).Add(gtx.Ops)
|
||||
return w(gtx)
|
||||
|
||||
Reference in New Issue
Block a user