gio
gio copied to clipboard
use iterators for events
Signed-off-by: ddkwork
This change will improve the event traversal syntax
for {
ev, ok := gtx.Event(pointer.Filter{
Target: r,
Kinds: pointer.Press | pointer.Release,
})
if !ok {
break
}
}
//------------------------------->
for e := range gtx.Events(pointer.Filter{Target: r,Kinds:pointer.Press | pointer.Release}) {
....
}
Using the range iteration will never traverse to the null pointer, and the return value bool will automatically stop traversing, so it is not necessary to judge bool downstream, and it will be automatically processed at the syntax level
i think we need apply this patch now.