Filter löschen
Filter löschen

button to activate textboxes in GUI

2 Ansichten (letzte 30 Tage)
Andy
Andy am 20 Sep. 2011
Kommentiert: Matthew am 22 Jul. 2019
Hi: How can i make it so that when i click on a button, it gathers information in textbox(s)? I have get(hObject, 'string') for my textbox, but how do i link this to another button? Thanks

Akzeptierte Antwort

William
William am 20 Sep. 2011
Use this:
exportwhatever = get(handles.("textboxname"),'string')
Put this code in the function callback. It will go to the text box and return in string format what is in the textbox.
  2 Kommentare
Andy
Andy am 20 Sep. 2011
thanks, exactly what i needed
Matthew
Matthew am 22 Jul. 2019
I used the function above but I still get an error:
"Undefined variable "handles" or class "handles.text1". Text1 is the tag of my textbox. But, i do not understand how to access the handles from my textbox.
I tried
set(handles.text1, 'String', works);
where works is just a string. So, how do I get to recognize "handles" from my textbox in my button callback function

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Grzegorz Knor
Grzegorz Knor am 20 Sep. 2011
  2 Kommentare
Andy
Andy am 20 Sep. 2011
I have a callback function for the textbox, i try to call it from the button function but its not working, can you give me an simple example?
Grzegorz Knor
Grzegorz Knor am 20 Sep. 2011
function test
uicontrol('Style','pushbutton','String','read','callback',@pb_clbck)
h = uicontrol('Style','Edit','String','write me!',...
'Units','normalized','Position',[.4 .45 .2 .1]);
function pb_clbck(src,evnt)
disp(get(h,'String'))
end
end

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu App Building finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by