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

select widget grows the enclosing window too wide #1247

Closed
shofster opened this issue Aug 11, 2020 · 6 comments
Closed

select widget grows the enclosing window too wide #1247

shofster opened this issue Aug 11, 2020 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@shofster
Copy link

Describe the bug:

I have several select widgets that get options added dduring runtime. Adding long options to these select widgets causes the width of the enclosing window to grow without bounds. In select.go, only using the PlaceHolder size and not including the maximum option size makes the button stay at it's original size and the display box expands into the window below to show all the options .

To Reproduce:

Steps to reproduce the behaviour:
create a select widget and add longer and longer options to the Options [] string.
open the select box after each add.
the enclosing window grow, and grows,....

Screenshots:

this image if after a homemade patch (see below) to select.go to keep the MinSize at the size of the PlaceHolder:

image

Example code:

func (s *selectRenderer) MinSize() fyne.Size {
s.combo.propertyLock.RLock()
defer s.combo.propertyLock.RUnlock()
min := fyne.MeasureText(s.combo.PlaceHolder, s.label.TextSize, s.label.TextStyle)
// for _, option := range s.combo.Options {
// optionMin := fyne.MeasureText(option, s.label.TextSize, s.label.TextStyle)
// min = min.Union(optionMin)
// }
min = min.Add(fyne.NewSize(theme.Padding()*4, theme.Padding()*2))
return min.Add(fyne.NewSize(theme.IconInlineSize()+theme.Padding(), 0))

Device (please complete the following information):

  • OS: Windows
  • Version: 10
  • Go version: go1.14.4 windows/amd64
  • Fyne version: 1.3
@andydotxyz andydotxyz added the enhancement New feature or request label Aug 14, 2020
@shofster
Copy link
Author

shofster commented Sep 1, 2020

JAVAfx handles this by leaving the place holder as is and putting a check mark on the last selected item. The drop down is allowed to grow horizontally.

@andydotxyz
Copy link
Member

Thanks and sorry for the slow reply on this - I will aim to get that added shortly so it's in our next release

@andydotxyz
Copy link
Member

One assumes that when the item is selected it is expected that the select button will not expand to fit it?
I mean normally widgets should expand to fit their content, but in this case that seems undesirable :)

@shofster
Copy link
Author

The drop down box already expands to fit the items. But the place holder box affects the container in which it is displayed. In my version, I skip the sizing based on the max item. plus I just leave the "Place Holder" text alone. this is what javafx does, with the exception of putting a check mark on the last item selected. In my usage, I operate on the selected item and having a check / highlight is unnecessary

andydotxyz added a commit to andydotxyz/fyne that referenced this issue Sep 27, 2020
Biggest change is that the drop-down can be larger than button.
Also button will not grow to fit selected item.

Fixes fyne-io#1247
@andydotxyz
Copy link
Member

The PR should contain a solution that works for you, feel free to test :)

@shofster
Copy link
Author

It works as I would have desired. Changing the padding was "fyne" with me :-)). I have 2 Selects in a Hbox surrounded and separated by Buttons (i.e. BBBBSBSBB). The padding and BOLD make the 2 Selects stand out.

andydotxyz added a commit that referenced this issue Oct 1, 2020
Biggest change is that the drop-down can be larger than button.
Also button will not grow to fit selected item.

Fixes #1247
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants