source: trunk/src/keyboard_callback.m @ 35

Last change on this file since 35 was 11, checked in by gostiaux, 15 years ago
File size: 1.8 KB
Line 
1%'keyboard_callback:' function activated when a key is pressed on the keyboard
2%-----------------------------------
3function keyboard_callback(hObject,eventdata,handleshaxes)
4xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
5cur_axes=get(gcbf,'CurrentAxes');
6if ~isempty(cur_axes)
7    xlimit=get(cur_axes,'XLim');
8    ylimit=get(cur_axes,'Ylim');
9    dx=(xlimit(2)-xlimit(1))/10;
10    dy=(ylimit(2)-ylimit(1))/10;
11   
12    if isequal(xx,29)%move arrow right
13        xlimit=xlimit+dx;
14    elseif isequal(xx,28)%move arrow left
15        xlimit=xlimit-dx;
16    elseif isequal(xx,30)%move arrow up
17        ylimit=ylimit+dy;
18    elseif isequal(xx,31)%move arrow down
19        ylimit=ylimit-dy;
20    end
21    set(cur_axes,'XLim',xlimit)
22    set(cur_axes,'YLim',ylimit)
23end
24if ismember(xx,[8 127]) %if the delete or suppr key is pressed, delete the current object
25    currentobject=gco;
26    huvmat=findobj(allchild(0),'Name','uvmat');
27%     UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
28    hlist_object=findobj(huvmat,'Tag','list_object');
29    ObjIndex=get(hlist_object,'Value');
30    if ObjIndex>1
31        delete_object(ObjIndex)
32    end
33    if ishandle(currentobject)
34        tag=get(currentobject,'Tag');%tag of the current selected object
35        if isequal(tag,'proj_object')
36            delete_object(currentobject)
37        end
38    end
39elseif isequal(xx,112)%  key 'p'
40    uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
41elseif isequal(xx,109)%  key 'm'
42    uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
43end
44
45AxeData=get(cur_axes,'UserData');
46if isfield(AxeData,'ParentRect')% update the position of the parent rectangle represneting the field
47    hparentrect=AxeData.ParentRect;
48    rect([1 2])=[xlimit(1) ylimit(1)];
49    rect([3 4])=[xlimit(2)-xlimit(1) ylimit(2)-ylimit(1)];
50    set(hparentrect,'Position',rect)
51end
Note: See TracBrowser for help on using the repository browser.