Skip to content

Commit

Permalink
Merge pull request #2180 from Jacalz/select-slownesss
Browse files Browse the repository at this point in the history
Some simple optimizations for widget.Select
  • Loading branch information
Jacalz committed Apr 18, 2021
2 parents 0ba026f + 74d345c commit f07ef8e
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions widget/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,24 +224,19 @@ func (s *Select) object() fyne.Widget {
return nil
}

func (s *Select) optionTapped(text string) {
s.SetSelected(text)
s.popUp = nil
}

func (s *Select) popUpPos() fyne.Position {
buttonPos := fyne.CurrentApp().Driver().AbsolutePositionForObject(s.super())
return buttonPos.Add(fyne.NewPos(0, s.Size().Height-theme.InputBorderSize()))
}

func (s *Select) showPopUp() {
var items []*fyne.MenuItem
for _, option := range s.Options {
text := option // capture
item := fyne.NewMenuItem(option, func() {
s.optionTapped(text)
items := make([]*fyne.MenuItem, len(s.Options))
for i := range s.Options {
text := s.Options[i] // capture
items[i] = fyne.NewMenuItem(text, func() {
s.updateSelected(text)
s.popUp = nil
})
items = append(items, item)
}

c := fyne.CurrentApp().Driver().CanvasForObject(s.super())
Expand Down

0 comments on commit f07ef8e

Please sign in to comment.