When you specify a callback like this:
set(hObject,'windowbuttonmotionfcn',{@fh_wbmfcn,handles});
The value of handles
will always be the one you set at that point, since you're only passing the value of the handles
variable.
Alternatively, the following should work:
set(hObject,'windowbuttonmotionfcn', @(obj,evt) fh_wbmfc(obj,evt, guidata(gcbo));
This will evaluate guidata(gcbo)
always at execution time of the callback - and hence give you the current handles
value.
Alternative no. 2 (my personal preference):
% remove handles from callback definition
set(hObject,'windowbuttonmotionfcn', @fh_wbmfc);
% and get current handle value in the callback function:
def fh_wbmfc(object, evt)
handles = guidata(object);
...