I wanted the opening text in my Edit Text button to clear whenever a key was pressed, but never afterwards. I tried to do this using a "FirstEdit" field in handles set to "false" in opening function (after initializing Edit):
function GUI_OpeningFcn(...) % ...
set(handles.edit1,'String','Initial Text') handles.FirstEdit = true;
Then, I would modify edit1's keypress to wipe the text field once only:
function edit1_KeyPressFcn(...) %...
if handles.FirstEdit == true set(handles.edit1,'String','') handles.FirstEdit = false; end
Unfortunately, the FirstEdit variable resets to its initial (OpeningFcn) value after every button press. What am I not getting? Is there a way to implement this?
Best Answer