Pushbutton callback function reacts only after second press when cell in uitable was selected beforehand

1 view (last 30 days)
Hi,
I'm writing a switch rows function for a uitable which is started by a pushbutton in Matlab GUIDE. I've written the code which works fine though the problem is that I have to press the button twice as the corresponding callback function of the pushbutton is not started the first time.
I obviously need to select a cell in the table (I already got the indices via the cell selection callback function) and then press the pushbutton to do the actual switching. The callback function of the pushbutton should start immediately but it doesn't.
My Code is:
% --- Executes when selected cell(s) is changed in table_pathdata.
function table_pathdata_CellSelectionCallback(hObject, eventdata, handles)
% Read current cell indices
setappdata(hObject,'CurrentCell',eventdata.Indices);
Indices = getappdata(hObject,'CurrentCell');
assignin('base','Indices',Indices);
% --- Executes on button press in button_moverowup.
function button_moverowup_Callback(hObject, eventdata, handles)
'Teststring' % This String will only be displayed on second button press
% Switch code follows which is working fine (on second button press)
I hope someone can help with that problem. It might be very easy for experienced guys.
  8 Comments
Jeff Spector
Jeff Spector on 9 Sep 2014
I seem to be having this problem as well but I am using Java 1.6.0_65-b14-462-11M4609 with Apple Inc. Java HotSpot™ 64-Bit Server VM mixed mode
I have two different versions of my GUI the callback for a pushbutton is the same in both versions, but in one it works on the first click and in the other it takes two clicks..not sure why?

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 27 Aug 2014
I've seen this before. When my user enters some text into a cell of a uitable, and I want to do something in a pushbutton callback, the first push of the pushbutton doesn't do anything and they have to push/click the pushbutton a second time to do the callback of the push button. So I have to have the string of my pushbutton say "OK (Click twice when done)". I'm not sure what's going on but it's like the first click of the pushbutton merely steps editing of the uitable and changes focus from the table to the pushbutton, like it's just ending the editing session of the table or something. Sorry, I don't know of a fix but I'd like to.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!