Info

This question is closed. Reopen it to edit or answer.

Building a calculator, confused with GUI ButtonDownFct

1 view (last 30 days)
JP
JP on 1 Jul 2013
Closed: MATLAB Answer Bot on 20 Aug 2021
Hello, I am building a calculator from scratch and Im having trouble with the ButtonPressFct. I am trying to make it so I store a variable ONLY IF you press a certain button. In this case, Im trying to do it for the '+' button. Heres what I have and it is not working
function togglebutton12_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton12
global n1
if (get(handles.text1,'ButtonDownFct') ~= 'on'
n1 = get(handles.text1,'String');
else
n1 = 0;
end
textString = get(handles.text1,'String');
textString = '';
set(handles.text1,'String',textString)

Answers (0)

Community Treasure Hunt

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

Start Hunting!