Skip to content

ebiten.SyncWithFPS breaks TextField cursor position #54

Description

@venning

When using ebiten.SetTPS(ebiten.SyncWithFPS), the cursor position of every ctx.TextField() moves to the left at the speed of one character per tick-frame.

This means that, when typing, every new character is inserted in the left-most position. This also means that, when clicking the text field, the insertion cursor moves to the position of the click correctly but then moves left at the rate of one character per tick-frame (until stopping at the first position).

This is a regression with DebugUI v0.3.0 (Ebitengine v2.10.3). When downgrading to DebugUI v0.2.0 (Ebitengine v2.9.11), there is no issue.

This is not a high priority for me personally; I don't need text fields much, so I can just type everything backwards when I do.


Reproducible example:

package main

import (
	"image"

	"github.com/ebitengine/debugui"
	"github.com/hajimehoshi/ebiten/v2"
)

var text string

type Game struct {
	debugui debugui.DebugUI
}

func (g *Game) Update() error {
	_, err := g.debugui.Update(func(ctx *debugui.Context) error {
		ctx.Window("Debugui Window", image.Rect(0, 0, 320, 240), func(layout debugui.ContainerLayout) {
			ctx.TextField(&text)
		})
		return nil
	})
	return err
}

func (g *Game) Draw(screen *ebiten.Image) {
	g.debugui.Draw(screen)
}

func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
	return outsideWidth, outsideHeight
}

func main() {
	ebiten.SetTPS(ebiten.SyncWithFPS) // comment this line out to fix the problem
	if err := ebiten.RunGame(&Game{}); err != nil {
		panic(err)
	}
}

Notes:

This was done with an English-language OS setup.
macOS 15.8

EDIT: Also, arbitrary values for ebiten.SetTPS, like 10 or 200, do not have a problem.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions