How to edit text box

조회 수: 1 (최근 30일)
Amanda
Amanda 2022년 11월 14일
편집: Chandler Hall 2022년 11월 15일
I have a edit box and a push button I want to make the push button do whatever I put in the edit box but I dont know how to do this
  댓글 수: 2
Chandler Hall
Chandler Hall 2022년 11월 15일
Are you sure drop-down box is not more appropriate? What sort of strings do you expect the user to input and how do you want that to correlate with the outcome?
Amanda
Amanda 2022년 11월 15일
Im trying to use it for a robot maze I want the person to put in a number that correlates to steps for the robot and when they hit the push button the robot takes that about of steps.

댓글을 달려면 로그인하십시오.

답변 (1개)

Chandler Hall
Chandler Hall 2022년 11월 15일
편집: Chandler Hall 2022년 11월 15일
fig = uifigure;
edit = uieditfield(fig, 'numeric');
btn = uibutton(fig, 'position', [200 100 100 22]);
label = uilabel(fig, 'position', [350 100 100 22]);
btn.ButtonPushedFcn = {@button_pushed, edit, label};
function button_pushed(obj, event, edit, label)
use_value(edit.Value, label);
end
function use_value(user_in, label)
label.Text = string(user_in);
end
See this article for a description about the unused arguments in button_pushed.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by