Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing #959 textview mouse out of bounds fix #963

Merged
merged 2 commits into from
Apr 3, 2024

Conversation

digitallyserviced
Copy link
Contributor

#959 bails if user clicks on border of textview when regions enabled

  • added *Box.InInnerRect(x,y int) helper to check if some coord is inside the inner rect (inside border/padding)
  • added check using the helper within *TextView mouse handler to ensure that if regions are enabled, and will be checked, that the event occurred WITHIN the inner rect since borders/padding are excluded
package main

import (
        "fmt"
        "log"

        "github.com/rivo/tview"
)

func main() {
        tabs := tview.NewTextView().SetRegions(true)
        tabs.SetBorder(true)
				tabs.SetDynamicColors(true)


        myApp := tview.NewApplication()
        myApp.EnableMouse(true)
				// tabs.SetToggleHighlights(true)

        myFlex := tview.NewFlex().SetDirection(tview.FlexRow).
                AddItem(
                        tview.NewFlex().
                                AddItem(tabs, 30, 0, false),
                        5, 0, false,
                )

        fmt.Fprintf(tabs, `
["%s"][white]%s[""]
[red] vv %s vv
["%s"][green]%s[""]
`, "0", "Anything", "Long Text","2","Anythong")

        if err := myApp.SetRoot(myFlex, true).Run(); err != nil {
                log.Fatal(err)
        }
}

Peek 2024-03-28 20-25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants