1

I am crossing a strange problem, I have an uitable, I want to have new outputs from Network inputs and when I change input values in uitable to get new outputs I have to press pushbutton twice. I have searched it there are lots of questions about this issue and I still didn't get the exact answer. Can anyone of you give me an idea how to figure out about this problem?

Here is code of uitable:

 t = uitable('Parent', f, 'Position', [0 60 260 400],...
        'Data',table_data,...
        'ColumnName',cnames,...
        'RowName',rnames,...
        'ColumnFormat',ColumnFormat,...
        'ColumnEditable',ColumnEditable,...
        'Enable','on',...
        'Visible','on');   

 handles.pushbutton1 = uicontrol('Style','Pushbutton',...
  'Units','Pixels',...
  'Position',[210 470 100 30],...
  'String','Simulate Network',...
  'callback',@Simulate_Callback); 

enter image description here

For instance in uitable when I changed Satznummer to a new value then I have to press Simulate Network twice till I get the new outputs.

I appreciate for any answer. Thanks.

Robert Seifert
  • 25,078
  • 11
  • 68
  • 113
mari
  • 107
  • 1
  • 10
  • If you hit return, or click anywhere inside the figure after you have changed Satznummer, do you still have to press Simulate Network twice? – Jonas Feb 06 '15 at 14:33
  • You might want to try giving pushbutton1 the same parent as the uitable to see if that changes the behavior. – Lukeclh Feb 06 '15 at 14:54

1 Answers1

1

In the uitable, when you edit a value, you need to change focus from the edit field to the figure, and only then will a button press register.

By double-clicking on the button, you are changing focus on the first click, and activating the button on the second click. You could also change focus to the figure by hitting return, or by clicking anywhere else on the figure.

The reason the change-focus-event is necessary is that while you're editing, pressing buttons should result in text appearing/disappearing, rather than executing any other action you may have bound to the KeyPress callback of the figure. In addition, changing the focus is what fires the callback of the table.

Jonas
  • 74,690
  • 10
  • 137
  • 177