Home > . > keyboard_callback.m

# keyboard_callback

## PURPOSE

'keyboard_callback:' function activated when a key is pressed on the keyboard

## SYNOPSIS

function keyboard_callback(hObject,eventdata,handleshaxes)

## DESCRIPTION

    'keyboard_callback:' function activated when a key is pressed on the keyboard
    -----------------------------------

## CROSS-REFERENCE INFORMATION

This function calls:

- delete_object 'delete_object': delete a projection object, defined by its index in the Uvmat list or by its graphic handle
- uvmat 'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization

This function is called by:

- mouse_up 'mouse_up': function activated when the mouse button is released

## SOURCE CODE

    0001 %'keyboard_callback:' function activated when a key is pressed on the keyboard
    0002 %-----------------------------------
    0003 function keyboard_callback(hObject,eventdata,handleshaxes)
    0004 xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
    0005 cur_axes=get(gcbf,'CurrentAxes');
    0006 if ~isempty(cur_axes)
    0007     xlimit=get(cur_axes,'XLim');
    0008     ylimit=get(cur_axes,'Ylim');
    0009     dx=(xlimit(2)-xlimit(1))/10;
    0010     dy=(ylimit(2)-ylimit(1))/10;
    0011
    0012     if isequal(xx,29)%move arrow right
    0013         xlimit=xlimit+dx;
    0014     elseif isequal(xx,28)%move arrow left
    0015         xlimit=xlimit-dx;
    0016     elseif isequal(xx,30)%move arrow up
    0017         ylimit=ylimit+dy;
    0018     elseif isequal(xx,31)%move arrow down
    0019         ylimit=ylimit-dy;
    0020     end
    0021     set(cur_axes,'XLim',xlimit)
    0022     set(cur_axes,'YLim',ylimit)
    0023 end
    0024 if isequal(xx,8)%if the delete key is pressed, delete the current object
    0025     currentobject=gco;
    0026     huvmat=findobj(allchild(0),'Name','uvmat');
    0027     UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
    0028     hlist_object=findobj(huvmat,'Tag','list_object');
    0029     ObjIndex=get(hlist_object,'Value');
    0030     if ObjIndex>1
    0031         delete_object(ObjIndex)
    0032     end
    0033     if ishandle(currentobject)
    0034         tag=get(currentobject,'Tag');%tag of the current selected object
    0035         if isequal(tag,'proj_object')
    0036             delete_object(currentobject)
    0037         end
    0038     end
    0039 elseif isequal(xx,112)%  key 'p'
    0040     uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
    0041 %     runplus_Callback(hObject,eventdata,handleshaxes)
    0042 elseif isequal(xx,109)%  key 'm'
    0043     uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
    0044 end
    0045
    0046 AxeData=get(cur_axes,'UserData');
    0047 if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
    0048     hparentrect=AxeData.ParentRect;
    0049     rect([1 2])=[xlimit(1) ylimit(1)];
    0050     rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
    0051     set(hparentrect,'Position',rect)
    0052 end