App not calling EditFieldValueChanging(app, event) callback when initial value is empty string.
I have a Sudoku app with text boxes (numerical, but it doesn’t seem to matter).
I want to control the user input with a ValueChanging callback. These callbacks are working once there’s already a value in them, but the callbacks aren’t called as the value changes from " " to "5555". I tried using a while loop to make them constantly observe the value of the box, but again it only works if the initial value isn’t an empty string…
I don’t know much about events, so if there is a way to force the active textbox to call the ValueChanging callback everytime a key is pressed, I think that is a workable solution.
Here is the callback code as it stands now:
function R11ValueChanging(app, event)
changingValue = event.Value;
while (changingValue ~= "" && changingValue ~= "1" && changingValue ~= "2" && changingValue ~= "3" && changingValue ~= "4" …
&& changingValue ~= "5" && changingValue ~= "6" && changingValue ~= "7" && changingValue ~= "8" && changingValue ~= "9")
app.R11.Value = "";
changingValue = "";
end
end
As I mentioned before, this code does dynamically clear the textbox if something invalid is typed, so in that sense it works, but it just doesn’t seem to recognize the ValueChanging event is occurring when the value begins as an empty string.
Edit: I just double-checked something I said, and I found out something weirder. The callback function is actually called. In debug mode, the invalid character gets deleted. But when I don’t have any breakpoints, the invalid character stays there…. so now I definitely need help with this…
Here is a video of what’s going on: https://youtu.be/SYnlw5GbDAQI have a Sudoku app with text boxes (numerical, but it doesn’t seem to matter).
I want to control the user input with a ValueChanging callback. These callbacks are working once there’s already a value in them, but the callbacks aren’t called as the value changes from " " to "5555". I tried using a while loop to make them constantly observe the value of the box, but again it only works if the initial value isn’t an empty string…
I don’t know much about events, so if there is a way to force the active textbox to call the ValueChanging callback everytime a key is pressed, I think that is a workable solution.
Here is the callback code as it stands now:
function R11ValueChanging(app, event)
changingValue = event.Value;
while (changingValue ~= "" && changingValue ~= "1" && changingValue ~= "2" && changingValue ~= "3" && changingValue ~= "4" …
&& changingValue ~= "5" && changingValue ~= "6" && changingValue ~= "7" && changingValue ~= "8" && changingValue ~= "9")
app.R11.Value = "";
changingValue = "";
end
end
As I mentioned before, this code does dynamically clear the textbox if something invalid is typed, so in that sense it works, but it just doesn’t seem to recognize the ValueChanging event is occurring when the value begins as an empty string.
Edit: I just double-checked something I said, and I found out something weirder. The callback function is actually called. In debug mode, the invalid character gets deleted. But when I don’t have any breakpoints, the invalid character stays there…. so now I definitely need help with this…
Here is a video of what’s going on: https://youtu.be/SYnlw5GbDAQ I have a Sudoku app with text boxes (numerical, but it doesn’t seem to matter).
I want to control the user input with a ValueChanging callback. These callbacks are working once there’s already a value in them, but the callbacks aren’t called as the value changes from " " to "5555". I tried using a while loop to make them constantly observe the value of the box, but again it only works if the initial value isn’t an empty string…
I don’t know much about events, so if there is a way to force the active textbox to call the ValueChanging callback everytime a key is pressed, I think that is a workable solution.
Here is the callback code as it stands now:
function R11ValueChanging(app, event)
changingValue = event.Value;
while (changingValue ~= "" && changingValue ~= "1" && changingValue ~= "2" && changingValue ~= "3" && changingValue ~= "4" …
&& changingValue ~= "5" && changingValue ~= "6" && changingValue ~= "7" && changingValue ~= "8" && changingValue ~= "9")
app.R11.Value = "";
changingValue = "";
end
end
As I mentioned before, this code does dynamically clear the textbox if something invalid is typed, so in that sense it works, but it just doesn’t seem to recognize the ValueChanging event is occurring when the value begins as an empty string.
Edit: I just double-checked something I said, and I found out something weirder. The callback function is actually called. In debug mode, the invalid character gets deleted. But when I don’t have any breakpoints, the invalid character stays there…. so now I definitely need help with this…
Here is a video of what’s going on: https://youtu.be/SYnlw5GbDAQ events, matlab, app designer MATLAB Answers — New Questions