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/SYnlw5GbDAQ
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Manage Products についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!