Skip to content

Single line Entry throws away selected text on submission #4026

Closed
@Goltanju

Description

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

Pretty much the title, fairly simple bug I think. The single line entry will discard any selected text on submit.

How to reproduce

With a single line entry:

  1. Type in "abc" and hit enter: you get "abc" ✔️
  2. Type in "abc" hit ctrl+a to select all and hit enter: you get "" 😢
  3. Type in "abc" select just the b and hit enter: you get "ac" 😢

Screenshots

No response

Example code

package main

import (
        "fmt"
        "image/color"

        "fyne.io/fyne/v2"
        "fyne.io/fyne/v2/app"
        "fyne.io/fyne/v2/canvas"
        "fyne.io/fyne/v2/container"
        "fyne.io/fyne/v2/theme"
        "fyne.io/fyne/v2/widget"
)

func main() {
        application := app.NewWithID("test-gui")
        window := application.NewWindow("Test GUI")
        monospace := fyne.MeasureText("M", theme.TextSize(), fyne.TextStyle{Monospace: true})
        min := canvas.NewRectangle(color.RGBA{})
        min.SetMinSize(fyne.NewSize(monospace.Width*20, monospace.Height*5))
        entry := widget.NewEntry()
        label := widget.NewLabel("")
        entry.OnSubmitted = func(v string) {
                label.SetText(fmt.Sprintf("%q", v))
        }
        window.SetContent(container.NewMax(min, container.NewGridWithRows(2, entry, label)))
        window.Show()
        application.Run()
}

Fyne version

develop

Go compiler version

1.20.5

Operating system and version

Windows 11

Additional Information

No response

Activity

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

Metadata

Assignees

No one assigned

    Labels

    unverifiedA bug that has been reported but not verified

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions