@@ -17,6 +17,8 @@ type CompletionEntry struct {
1717
1818 CustomCreate func () fyne.CanvasObject
1919 CustomUpdate func (id widget.ListItemID , object fyne.CanvasObject )
20+
21+ impl fyne.Widget
2022}
2123
2224// NewCompletionEntry creates a new CompletionEntry which creates a popup menu that responds to keystrokes to navigate through the items without losing the editing ability of the text input.
@@ -26,6 +28,20 @@ func NewCompletionEntry(options []string) *CompletionEntry {
2628 return c
2729}
2830
31+ // ExtendBaseWidget is used by an extending widget to make use of CompletionEntry functionality.
32+ func (c * CompletionEntry ) ExtendBaseWidget (wid fyne.Widget ) {
33+ c .impl = wid
34+ c .Entry .ExtendBaseWidget (wid )
35+ }
36+
37+ // super returns the extending widget if set, otherwise the CompletionEntry itself.
38+ func (c * CompletionEntry ) super () fyne.Widget {
39+ if c .impl != nil {
40+ return c .impl
41+ }
42+ return c
43+ }
44+
2945// HideCompletion hides the completion menu.
3046func (c * CompletionEntry ) HideCompletion () {
3147 if c .popupMenu != nil {
@@ -84,7 +100,7 @@ func (c *CompletionEntry) ShowCompletion() {
84100 c .navigableList .UnselectAll ()
85101 c .navigableList .selected = - 1
86102 }
87- holder := fyne .CurrentApp ().Driver ().CanvasForObject (c )
103+ holder := fyne .CurrentApp ().Driver ().CanvasForObject (c . super () )
88104
89105 if c .popupMenu == nil {
90106 c .popupMenu = widget .NewPopUp (c .navigableList , holder )
@@ -96,7 +112,7 @@ func (c *CompletionEntry) ShowCompletion() {
96112
97113// calculate the max size to make the popup to cover everything below the entry
98114func (c * CompletionEntry ) maxSize () fyne.Size {
99- cnv := fyne .CurrentApp ().Driver ().CanvasForObject (c )
115+ cnv := fyne .CurrentApp ().Driver ().CanvasForObject (c . super () )
100116
101117 if c .itemHeight == 0 {
102118 // set item height to cache
@@ -105,7 +121,7 @@ func (c *CompletionEntry) maxSize() fyne.Size {
105121
106122 canvasSize := cnv .Size ()
107123 entrySize := c .Size ()
108- entryPos := fyne .CurrentApp ().Driver ().AbsolutePositionForObject (c )
124+ entryPos := fyne .CurrentApp ().Driver ().AbsolutePositionForObject (c . super () )
109125 listHeight := float32 (len (c .Options ))* (c .itemHeight + 2 * theme .Padding ()+ theme .SeparatorThicknessSize ()) + 2 * theme .Padding ()
110126 maxHeight := canvasSize .Height - entryPos .Y - entrySize .Height - 2 * theme .Padding ()
111127
@@ -118,7 +134,7 @@ func (c *CompletionEntry) maxSize() fyne.Size {
118134
119135// calculate where the popup should appear
120136func (c * CompletionEntry ) popUpPos () fyne.Position {
121- entryPos := fyne .CurrentApp ().Driver ().AbsolutePositionForObject (c )
137+ entryPos := fyne .CurrentApp ().Driver ().AbsolutePositionForObject (c . super () )
122138 return entryPos .Add (fyne .NewPos (0 , c .Size ().Height ))
123139}
124140
0 commit comments