MobileTextField.TextChanged event fires if changed programmatically

Feedback Case Number: 71727

I use the Activated event of a MobileScreen to populate MobileTextFields with the current value of variables which the user can change.

I’ve found that this fires the TextChanged event of the MobileTextField, resulting in unnecessary/unwanted code execution.

The documentation states that this behavior shouldn’t happen:
https://documentation.xojo.com/api/user_interface/mobile/mobiletextfield.html#mobiletextfield-textchanged

I’ve added a note to the closely related Issue above to add that this is also a Mobile problem, not just MacOS. Please Thumb the Issue if you agree.

It would be the only platform in which it did not happen.

It’s really simple to work around. Disable the TextField, make your change, re-enable the text field. In the TextChanged handler, the very first line:

if not me.Enabled then return

I actually strongly disagree with the complaint that events are raised when code makes changes. I want the events to fire when the events occur. Always.

It is easier to ignore an event you don’t want than it is to try and get an event you were never given.

3 Likes

The Issue says that it doesn’t do this on Windows and Linux.

Thanks for the workaround. I already figured one out for my circumstances.

I can see that it would be a problem to change this behavior if folks have been relying on it, but I seriously doubt that most even know that this is happening. I stumbled across it because it was causing performance issues by unnecessarily recreating a displayed PDF.

I think you missunderstood my case.

I’m asking for SearchField.TextChanged to work the same as TextField.TextChanged event.

I guess, as SearchField is newer, the developer that worked with SearchField decided that TextChanged event should not fire if the change was programmatically. This is inconsistent and should be fixed (I know it may cause problems with people using SearchField.TextChanged but I don’t see any other option).

MobileTextField.TextChanged is working as it should and the documentation needs update.

If enough users want/need an Event that only detects Text Changed by user, Xojo should add TextChangedByUser event.

As Tim said:

Does that mean that SearchField.TextChanged event fires when is changed programmatically? Have you tested?

No I haven’t tested. This was a note in the Issue by a Xojo person.

i wish we have a single event with a info it was changed by code or user.

i had success using a app status enumeration and based on this i act in the events.
better than using a flag.

and i forgot which project it was :frowning:

1 Like

This changed very recently, in Xojo 2024r3 or r4.
I had to check every occurrence of TextChanged in my app this week when I upgraded a project from r2 to r4.

2 Likes