Skip to content

Commit a72497e

Browse files
author
rj
committed
Fixed bug with focus and blur events for the SelectInput on linux. This control is a container, and focus and blur events need to be attached to the child.
1 parent 1f12768 commit a72497e

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

selectinput_linux.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ func (w *SelectInput) mount(parent base.Control) (base.Element, error) {
3939

4040
control.Connect("destroy", selectinputOnDestroy, retval)
4141
retval.shChange = setSignalHandler(&control.Widget, 0, w.OnChange != nil, "changed", selectinputOnChanged, retval)
42-
retval.onFocus.Set(&control.Widget, w.OnFocus)
43-
retval.onBlur.Set(&control.Widget, w.OnBlur)
42+
if child, err := control.GetChild(); err == nil {
43+
child.SetCanFocus(true)
44+
retval.onFocus.Set(child, w.OnFocus)
45+
retval.onBlur.Set(child, w.OnBlur)
46+
}
4447
control.Show()
4548

4649
return retval, nil
@@ -107,6 +110,16 @@ func (w *selectinputElement) propsItems() []string {
107110
return items
108111
}
109112

113+
func (w *selectinputElement) TakeFocus() bool {
114+
widget, err := w.comboboxtext().GetChild()
115+
if err != nil {
116+
return false
117+
}
118+
119+
control := Control{widget}
120+
return control.TakeFocus()
121+
}
122+
110123
func (w *selectinputElement) updateProps(data *SelectInput) error {
111124
cbt := w.comboboxtext()
112125

@@ -123,7 +136,9 @@ func (w *selectinputElement) updateProps(data *SelectInput) error {
123136
cbt.SetSensitive(!data.Disabled)
124137
w.onChange = data.OnChange
125138
w.shChange = setSignalHandler(&cbt.Widget, w.shChange, data.OnChange != nil, "changed", selectinputOnChanged, w)
126-
w.onFocus.Set(&cbt.Widget, data.OnFocus)
127-
w.onBlur.Set(&cbt.Widget, data.OnBlur)
139+
if child, err := cbt.GetChild(); err == nil {
140+
w.onFocus.Set(child, data.OnFocus)
141+
w.onBlur.Set(child, data.OnBlur)
142+
}
128143
return nil
129144
}

0 commit comments

Comments
 (0)