source: trunk/src/keyboard_callback.m @ 622

Last change on this file since 622 was 622, checked in by sommeria, 8 years ago

mouse system for uvmat imrpoved

File size: 2.9 KB
Line 
1%'keyboard_callback:' function activated when a key is pressed on the keyboard
2%-----------------------------------
3function keyboard_callback(hObject,eventdata,handleshaxes)
4cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject
5if ~isempty(eventdata) && isnumeric(eventdata)
6    xx=eventdata; % keyboard_callback called by mouse_down
7else
8xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
9end
10switch xx
11    case {29,28,30,31}    %arrows for displacement
12        if ~isempty(cur_axes)
13            xlimit=get(cur_axes,'XLim');
14            ylimit=get(cur_axes,'Ylim');
15            dx=(xlimit(2)-xlimit(1))/10;
16            dy=(ylimit(2)-ylimit(1))/10;
17            if isequal(xx,29)%move arrow right
18                xlimit=xlimit+dx;
19            elseif isequal(xx,28)%move arrow left
20                xlimit=xlimit-dx;
21            elseif isequal(xx,30)%move arrow up
22                ylimit=ylimit+dy;
23            elseif isequal(xx,31)%move arrow down
24                ylimit=ylimit-dy;
25            end
26            set(cur_axes,'XLim',xlimit)
27            set(cur_axes,'YLim',ylimit)
28            hfig=hObject; %master figure
29            AxeData=get(cur_axes,'UserData');
30            if isfield(AxeData,'ParentRect')% update the position of the parent rectangle representing the field
31                hparentrect=AxeData.ParentRect;
32                rect([1 2])=[xlimit(1) ylimit(1)];
33                rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
34                set(hparentrect,'Position',rect)
35                hfig=get(hparentrect,'parent');
36                hfig=get(hfig,'parent');
37            elseif isfield(AxeData,'LimEditBox')&& isequal(AxeData.LimEditBox,1)% update display of the GUI containing the axis (uvmat or view_field)
38                hh=guidata(hfig);
39                if isfield(hh,'num_MinX')
40                    set(hh.num_MinX,'String',num2str(xlimit(1)))
41                    set(hh.num_MaxX,'String',num2str(xlimit(2)))
42                    set(hh.num_MinY,'String',num2str(ylimit(1)))
43                    set(hh.num_MaxY,'String',num2str(ylimit(2)))
44                end
45            end
46        end
47    case {8, 127} %if the delete or suppr key is pressed, delete the current object
48        currentobject=gco;
49        huvmat=findobj(allchild(0),'tag','uvmat');
50        hlist_object=findobj(huvmat,'Tag','list_object_1');
51        ObjIndex=get(hlist_object,'Value');
52        if ObjIndex>1
53            delete_object(ObjIndex)
54        end
55        if ishandle(currentobject)
56            tag=get(currentobject,'Tag');%tag of the current selected object
57            if isequal(tag,'proj_object')
58                delete_object(currentobject)
59            end
60        end
61    case 112%  key 'p'
62        uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
63    case 109%  key 'm'
64        uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
65end
66
Note: See TracBrowser for help on using the repository browser.