Hi,
I understand that you want to insert text next to the existing text when a button is clicked.
This can be done by appending new text to the existing text as below.
I created a textbox and button as shown below.
Whenever the 'Button' is clicked, the current time is appened next to the existing text in the textbox.
Please check callback function associated with Button click below. This function appends next text whenever 'Button' is clicked.
function ButtonPushed(app, event)
currentTime = char(datetime('now', 'Format', 'HH:mm:ss'));
if isempty(app.TextArea.Value)
newContent = currentTime;
newContent = [char(app.TextArea.Value), ', ', currentTime];
app.TextArea.Value = newContent;
Similarly, one more use case is below. Whenever, the button is clicked a new number is appended to the text box, which counts the number of times the button was clicked. And this time, there is no space or comma between these numbers.
Please check the screenshot of the App below.
Add a property called ButtonClickCount as below.
properties (Access = public)
ButtonClickCount double = 0;
Please check callback function associated with Button click below. This function appends next text whenever 'Button' is clicked.
function ButtonPushed(app, event)
app.ButtonClickCount = app.ButtonClickCount + 1;
countStr = num2str(app.ButtonClickCount);
newContent = [char(app.TextArea.Value), countStr];
app.TextArea.Value = newContent;
Hope this helps in resolving your query!