File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -953,10 +953,11 @@ func (e *Entry) cutToClipboard(clipboard fyne.Clipboard) {
953
953
e .copyToClipboard (clipboard )
954
954
e .setFieldsAndRefresh (e .eraseSelection )
955
955
e .propertyLock .RLock ()
956
+ content := e .Text
956
957
cb := e .OnChanged
957
958
e .propertyLock .RUnlock ()
958
959
if cb != nil {
959
- cb (e . Text )
960
+ cb (content )
960
961
}
961
962
e .Validate ()
962
963
}
@@ -1221,10 +1222,11 @@ func (e *Entry) selectingKeyHandler(key *fyne.KeyEvent) bool {
1221
1222
// clears the selection -- return handled
1222
1223
e .setFieldsAndRefresh (e .eraseSelection )
1223
1224
e .propertyLock .RLock ()
1225
+ content := e .Text
1224
1226
cb := e .OnChanged
1225
1227
e .propertyLock .RUnlock ()
1226
1228
if cb != nil {
1227
- cb (e . Text )
1229
+ cb (content )
1228
1230
}
1229
1231
e .Validate ()
1230
1232
return true
Original file line number Diff line number Diff line change @@ -287,6 +287,21 @@ func TestEntry_EraseSelection(t *testing.T) {
287
287
assert .Equal (t , - 1 , b )
288
288
}
289
289
290
+ func TestEntry_CallbackLocking (t * testing.T ) {
291
+ e := & Entry {}
292
+ called := 0
293
+ e .OnChanged = func (_ string ) {
294
+ e .propertyLock .Lock ()
295
+ called ++ // Just to not have an empty critical section.
296
+ e .propertyLock .Unlock ()
297
+ }
298
+
299
+ test .Type (e , "abc123" )
300
+ e .selectAll ()
301
+ e .TypedKey (& fyne.KeyEvent {Name : fyne .KeyBackspace })
302
+ assert .Equal (t , 7 , called )
303
+ }
304
+
290
305
func TestEntry_MouseClickAndDragOutsideText (t * testing.T ) {
291
306
entry := NewEntry ()
292
307
entry .SetText ("A\n B\n " )
You can’t perform that action at this time.
0 commit comments