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

Text wrapping is not working in dialogs #2602

Closed
HashimTheArab opened this issue Oct 31, 2021 · 11 comments
Closed

Text wrapping is not working in dialogs #2602

HashimTheArab opened this issue Oct 31, 2021 · 11 comments
Assignees
Labels
Bounty Tickets with this label rewards core contributors for completion bug Something isn't working

Comments

@HashimTheArab
Copy link

HashimTheArab commented Oct 31, 2021

Is your feature request related to a problem? Please describe:

When adding a label in dialog.CustomShow, if it's too long it'll go off the screen but if its wrapped it'll be a long vertical list
Normal
image
That same string wrapped with fyne.TextWrapWord
image

Describe the solution you'd like to see:

It would be nice to have it wrapped but not be constrained to a narrow vertical list, something like this
image
That image is photoshopped to show what it would look like

@Jacalz Jacalz changed the title Improve labels in dialog.CustomShow Text wrapping is not working in dialogs Oct 31, 2021
@Jacalz Jacalz added the bug Something isn't working label Oct 31, 2021
@Jacalz
Copy link
Member

Jacalz commented Oct 31, 2021

I think this might be considered more of a bug than a feature, so I changed this to a bug instead. Also, I think this is related to #1001 as well.

@williambrode
Copy link

I'm not sure what dialog.CustomShow is that the reporter is referring to. Doesn't seem to exist in the code base and they didn't include code.

For the broader subject of text wrapping not working - can we just add dialog.ShowErrorLong that uses a vertical scroll and TextWrapBreak? That is what I think most people actually want the behavior to be.

@andydotxyz
Copy link
Member

I'm not sure what dialog.CustomShow is that the reporter is referring to. Doesn't seem to exist in the code base and they didn't include code.

Probably a typo for dialog.ShowCustom

For the broader subject of text wrapping not working - can we just add dialog.ShowErrorLong that uses a vertical scroll and TextWrapBreak?

Simply inserting the scroll would cause it to collapse down, so we need to something extra to determine what a sensible size would be for content that could be scrolled. Either way making this change suffers the same bug that is demonstrated above - as in there is no defined and sensible minimum when you can wrap/scroll.

In summary I think adding scroll does not help the reported problem.

@williambrode
Copy link

williambrode commented Apr 14, 2022

From testing I believe this does what I want:

func ShowErrorLong(msg string, win *fyne.Window) {
	label := widget.NewLabel(msg)
	label.Wrapping = fyne.TextWrapBreak
	scroll := container.NewVScroll(label)
	errDialog := dialog.NewCustom("Error", "OK", container.NewMax(scroll), *win)
	factor := float32(0.40)
	winSize := (*win).Content().Size()
	errDialog.Resize(fyne.NewSize(winSize.Width*factor, winSize.Height*factor))
	errDialog.Show()
}

Where factor sets the percentage of the window size to use for the error dialog.

@andydotxyz
Copy link
Member

Setting a percentage of the window may make sense but why 40%? Won’t this get really tiny on an iPhone? Not sure the same factor applies to height and width as a portrait window will look super weird with this maths.

@matwachich
Copy link
Contributor

Why not using a percentage, but just
dlgSize = winSize - dlgShadowSize

so the dialog will have the maximum possible size to cover the entire window and show the gradient border

@andydotxyz
Copy link
Member

On larger screens this will look very strange.
I don't think there is a "simple" formula - probably some threshold where below it is max and above it is a percent.

@matwachich
Copy link
Contributor

What is sure is that a dialog should never be wider/higher than the parent window.

@Jacalz
Copy link
Member

Jacalz commented Jul 6, 2022

I agree. It also doesn’t, in my opinion, make sense to automatically pop out a dialog to a new window if the size is bigger than the parent.

@williambrode
Copy link

I forgot about this issue but just hit it again trying to use dialog.NewInformation. I imagine this must be a common problem for people right? Since the only way its not an issue is if the text width is less than the window width - right? Or perhaps people are inserting newline characters into their text directly?

@andydotxyz
Copy link
Member

We need to get this resolved - some algorithm to wrap where required - and use "most?" of the screen width instead of just the height...
$250 is currently allocated for eligible contributors completing this work (see Contributing: Membership).

@andydotxyz andydotxyz added the Bounty Tickets with this label rewards core contributors for completion label Feb 8, 2024
@dweymouth dweymouth self-assigned this Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bounty Tickets with this label rewards core contributors for completion bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants