TextField.Enabled = False clears field text

With Xojo 2021r3.1 if I create a new desktop project, add two DesktopButtons and one DesktopTextField to Windows1. In Button1.Pressed paste:

if TextField1.Enabled then
  TextField1.Enabled = False
else
  TextField1.Enabled = True
end if

In Button2.Pressed paste:

if TextField1.Enabled then
  TextField1.SelectAll  // Workaround fix for macOS
  TextField1.Enabled = False
else
  TextField1.Enabled = True
end if

Run app and enter text into the TextField. Clicking Button1 clears the text in the TextField, while clicking Button2 doesn’t.

Is this a known issue or still present in the current version of Xojo? I haven’t seen it in this forum or Xojo Issues. This bug is present on macOS - tested on Intel and Arm CPU, but not on Windows64.

It is the same in the latest version. Please file a bug report in Issues:
https://tracker.xojo.com/xojoinc/xojo/-/issues

https://tracker.xojo.com/xojoinc/xojo/-/issues/73323

Interestingly if you tab out of the TextField prior to clicking Button 1 everything works correctly.

It affects also Xojo 2021r2.1
Adding “clearfocus” in button1 does not clear the text:

ClearFocus
if TextField1.Enabled then
TextField1.Enabled = False
else
TextField1.Enabled = True
end if

It appears to be related to the EditField not completing the assignment fully when the button is clicked. I suspect anything that alters the focus or selection on the Edit Field would solve the problem. The bug is currently marked for attention for the next release 2023r2, so hopefully it will be fixed soon.

It looks like this bug was there since (at least) Xojo 2020r1. Fixed now.

Thank you for pointing this out and reporting it! :+1:

2 Likes

This may actually be the reason behind the IDE sometimes loosing pasted in values int the Inspector. I’ve never been able to tie it down enough to report it, but sometimes when you paste a value into the inspector and then click in another field it would fail to store the pasted value. For example Pasting into Height and then clicking in Top could cause the change to Height to be reverted. It was never that consistent though.

Thanks for the rapid fix.

1 Like

Indeed fixed in latest beta :slight_smile:

1 Like