Created
December 7, 2023 09:25
-
-
Save kmesiab/df01624a79a665fc4b8bf9fa609f77bc to your computer and use it in GitHub Desktop.
Fyne Rich Text - Resize Behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| "fyne.io/fyne/v2" | |
| "fyne.io/fyne/v2/app" | |
| "fyne.io/fyne/v2/container" | |
| "fyne.io/fyne/v2/widget" | |
| ) | |
| func main() { | |
| var size = fyne.NewSize(100, 100) | |
| application := app.New() | |
| richText := widget.NewRichTextFromMarkdown("Hello **world**!") | |
| canvas := container.NewBorder(nil, nil, richText, nil) | |
| window := application.NewWindow("") | |
| window.SetContent(canvas) | |
| window.Resize(size) | |
| // richtext: w: 12779520p-17 h: 9437184p-18 | |
| log.Printf("richtext: w: %b h: %b", | |
| richText.Size().Width, | |
| richText.Size().Height, | |
| ) | |
| richText.ParseMarkdown( | |
| "# - - - - - - - - - - - - - - - - - - - - - - - -", | |
| ) | |
| window.ShowAndRun() | |
| // richtext: w: 11305472p-15 h: 12058624p-17 | |
| log.Printf("richtext: w: %b h: %b", | |
| richText.Size().Width, | |
| richText.Size().Height, | |
| ) | |
| } | |
| // output: | |
| // richtext: w: 12779520p-17 h: 9437184p-18 | |
| // richtext: w: 11305472p-15 h: 12058624p-17 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
RichTextand its parent window are resized to fit the content, even if we specifywindow.SetFixedSize(true)herehttps://gist.github.com/kmesiab/df01624a79a665fc4b8bf9fa609f77bc#file-main-go-L23