ctrlutil.go
func NextControl(parent Control, curr Control, next bool) Control {
	fnTab := func(c Control) bool {
		isVisible := func() bool {
			ctrl := c.Parent()

			for ctrl != nil {
				if !ctrl.Visible() {
					return false
				}

				ctrl = ctrl.Parent()
			}

			return c.Visible()
		}

		return c.TabStop() && isVisible() && c.Enabled()
	}

	linear := getLinearControlList(parent, fnTab)

	if len(linear) == 0 {
		return nil
	}

	var pIndex, nIndex int

	for i, ch := range linear {
		if ch != curr {
			continue
		}

		pIndex = i - 1
		nIndex = i + 1
		break
	}

	if nIndex > len(linear)-1 {
		nIndex = 0
	}

	if pIndex < 0 {
		pIndex = len(linear) - 1
	}

	if next {
		return linear[nIndex]
	} else {
		return linear[pIndex]
	}
}
func NextControl(parent Control, curr Control, next bool) Control {
	fnTab := func(c Control) bool {
		isVisible := func() bool {
			ctrl := c.Parent()

			for ctrl != nil {
				if !ctrl.Visible() {
					return false
				}

				ctrl = ctrl.Parent()
			}

			return c.Visible()
		}

		return c.TabStop() && isVisible() && c.Enabled()
	}

	linear := getLinearControlList(parent, fnTab)

	if len(linear) == 0 {
		return nil
	}

	var pIndex, nIndex int

	for i, ch := range linear {
		if ch != curr {
			continue
		}

		pIndex = i - 1
		nIndex = i + 1
		break
	}

	if nIndex > len(linear)-1 {
		nIndex = 0
	}

	if pIndex < 0 {
		pIndex = len(linear) - 1
	}

	if next {
		return linear[nIndex]
	} else {
		return linear[pIndex]
	}
}
func NextControl ( parent Control , curr Control , next bool ) Control { fnTab := func ( c Control ) bool { isVisible := func ( ) bool { ctrl := c . Parent ( ) for ctrl != nil { if ! ctrl . Visible ( ) { return false } ctrl = ctrl . Parent ( ) } return c . Visible ( ) } return c . TabStop ( ) && isVisible ( ) && c . Enabled ( ) } linear := getLinearControlList ( parent , fnTab ) if len ( linear ) == 0 { return nil } var pIndex , nIndex int for i , ch := range linear { if ch != curr { continue } pIndex = i - 1 nIndex = i + 1 break } if nIndex > len ( linear ) - 1 { nIndex = 0 } if pIndex < 0 { pIndex = len ( linear ) - 1 } if next { return linear [ nIndex ] } else { return linear [ pIndex ] } }
// NextControl returns the next or previous child (depends on next parameter)
// that has tab-stop feature on. Used by library when processing TAB key
NextControl returns the next or previous child ( depends on next parameter ) that has tab - stop feature on . Used by library when processing TAB key