How prevent the tab key from exiting the Text Area component
21 次查看(过去 30 天)
显示 更早的评论
Problem: The tab key changes the focus of the Text Area ui component, when running app designer apps.
I want to have a multi line text editor (Text Area) that inserts the tab character into the text I'm editing, like a programmers editor.
Is there some way to disable this behavior.
0 个评论
采纳的回答
dpb
2024-1-24
移动:dpb
2024-1-24
Using the uitextarea <callback function> would be the only way, but I don't think you will be able to make it work for the <\t> character; it is treated especially to change focus of the control as you are awared. On top of this, to do it with the ValueChangingFcn callback, be aware of the following Note:
"Avoid updating the Value property of the TextArea object from within its own ValueChangingFcn callback, as this might result in unexpected behavior. To update the text area value in response to user input, use a ValueChangedFcn callback instead."
It would seem you would have to not only trap the character but if it were a tab, then reset focus back and then where is the user cursor on entry, etc., etc., etc., ...
Hence, while I doubt if even this would work well, the only way I see one might be able to do it would be to keep a running position counter and then insert tabs in the object when the user exits...
My guess this is simply not going to be feasible; you would need a custom-written UI component methinkks.
2 个评论
dpb
2024-1-27
Well, I for one had never thought of trying to build a code editor in App Designer.
I don't know how big a demand there might be, but if you see it and think it is a need, give the example use case and submit an official enhancement request.
It would seem something such as your workaround would be the logical way anyway, rewriting yet another code editor instead of linking to an existing one seems like a lot of effort and reinventing the wheel...
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!