gio icon indicating copy to clipboard operation
gio copied to clipboard

use iterators for events

Open ddkwork opened this issue 8 months ago • 1 comments

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

ddkwork avatar May 06 '25 06:05 ddkwork

IMG_20250506_232229.jpg

i think we need apply this patch now.

ddkwork avatar May 06 '25 15:05 ddkwork