1 | %'mouse_alt_gui': function activated when the right mouse button is pressed on a GUI (callback for 'WindowButtonDownFcn') |
---|
2 | % it displays a msg box with zoom of the current uicontrol display |
---|
3 | %------------------------------------------------------------------------ |
---|
4 | function mouse_alt_gui(hObject,eventdata,handles) |
---|
5 | %------------------------------------------------------------------------ |
---|
6 | if isequal(get(hObject,'SelectionType'),'alt') |
---|
7 | set(hObject,'Units','pixels') |
---|
8 | series_pos=get(hObject,'Position');%position of the current GUI (in pixels), as selected by the mouse |
---|
9 | set(hObject,'Units','normalized') |
---|
10 | xy_fig=get(hObject,'CurrentPoint');% current point of the current GUI |
---|
11 | hchild=get(hObject,'Children');%handles of all objects in the current GUI |
---|
12 | %% loop on all the objects in the current figure (selected by the last mouse click) |
---|
13 | for ichild=1:length(hchild) |
---|
14 | obj_pos=get(hchild(ichild),'Position');%position of the object |
---|
15 | if numel(obj_pos)>=4 && xy_fig(1) >=obj_pos(1) && xy_fig(2) >= obj_pos(2)&& xy_fig(1) <=obj_pos(1)+obj_pos(3) && xy_fig(2) <= obj_pos(2)+obj_pos(4); |
---|
16 | htype=get(hchild(ichild),'Type');%type of object child of the current figure |
---|
17 | %if the mouse is over a uicontrol, look at the data |
---|
18 | if isequal(htype,'uicontrol') && isequal(get(hchild(ichild),'Visible'),'on') |
---|
19 | msg_pos(1:2)=series_pos(1:2)+obj_pos(1:2).*series_pos(3:4); |
---|
20 | msgbox_uvmat(['uicontrol: ' get(hchild(ichild),'Tag')],'',get(hchild(ichild),'String'),msg_pos) |
---|
21 | break |
---|
22 | end |
---|
23 | end |
---|
24 | end |
---|
25 | set(hObject,'Units','pixels') |
---|
26 | end |
---|