Skip to content

Domain entry special cases #4891

Closed Answered by andydotxyz
w3suli asked this question in Q&A
May 28, 2024 · 3 comments · 11 replies
Discussion options

You must be logged in to vote
// Package main loads a very basic Hello World graphical application.
package main

import (
	"fmt"

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

func main() {
	a := app.New()
	w := a.NewWindow("Hello")

	hello := widget.NewLabel("")
	ent := widget.NewEntry()
	selstart := -1
	lastCol := 0
	ent.OnCursorChanged = func() {
		pos := ent.CursorColumn
		text := ent.SelectedText()
		if text == "" {
			hello.SetText("No selection")
			lastCol = pos
			selstart = -1
			return
		}
		pos2 := 0
		if selstart == -1 {
			selstart = lastCol
		}

		if ent.CursorColumn >= selstart {
			pos = ent.CursorColumn - len(text)
		}
		pos2 = pos + len(text)

		info := fmt.Sprintf(

Replies: 3 comments 11 replies

Comment options

You must be logged in to vote
8 replies
@dweymouth
Comment options

@w3suli
Comment options

@andydotxyz
Comment options

@w3suli
Comment options

@andydotxyz
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@w3suli
Comment options

@andydotxyz
Comment options

Answer selected by w3suli
@w3suli
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question A question has been asked
3 participants
Converted from issue

This discussion was converted from issue #4889 on May 28, 2024 21:36.