MATLAB: App Designer button callback

app designercallbackslamp

function GOButtonPushed(app, event)
app.Lamp.Color = 'yellow';
% Some long computation.
app.Lamp.Color = 'green';
end
If I have the above code the lamp never turns yellow. It seems like the UI doensn't refresh until the entire callback finishes.
Is there a way to fix this?

Best Answer

You can force a graphics update with drawnow, or by introducing a small pause (in general I see people using pause(0.01) or a similar amount of time). Either will flush the queue of graphics updates.