Question: In matlab if I've a context menu with handle `cxmenu_Options` which is linked to different three `uicontrol` objects.

**Inside the context menu callback function:**

**Code Demo:**

```
function demoOnContextMenus
hFigure = figure;
hControl = uicontrol(                ...
    'Parent' , hFigure            , ...
    'Style'  , 'Edit'             , ...
    'Position' , [200 200 180 40] , ...
    'Tag'    , 'IamControl'       , ...
    'String' , 'UI-Control');

hCxMenu = uicontextmenu(            ...
    'Tag'    , 'IamMenu'       , ...
    'Callback',@CxMenuCallback);

set(hControl,'UIContextMenu',hCxMenu);

    function CxMenuCallback(objectHandle,eventData)
        tag = get(gcbo,'tag');
        helpdlg(tag);
    end
end

```

How Can I get the handle of the `uicontrol` which the context menu has been called from ?

Answer: 
There are two ways to access the handle:

`gco` returns the handle of the currently selected object. Thus `tag = get(gco,'tag')` will return `IamControl`.

Alternatively, you can pass the handle directly to the callback (in case the hierarchy becomes more complicated, since `gco` will only give you the top-level handle of the eventual chain):

```
handleToPass = hControl;

hCxMenu = uicontextmenu(            ...
    'Tag'    , 'IamMenu'       , ...
    'Callback',@(oh,evt)CxMenuCallback(oh,evt,handleToPass));

set(hControl,'UIContextMenu',hCxMenu);

    function CxMenuCallback(objectHandle,eventData,handleOfCaller)
        tag = get(handleOfCaller,'tag');
        helpdlg(tag);
    end

```
Using Matlab's guide environment I have found another way to determine the caller.

The command gco (get current object) simply did the job.

In my case the context menu provides the option to open a path specified in an "Edit Text" object in Windows Explorer.

```
function open_in_browser_Callback(hObject, eventdata, handles)

cur_obj=gco;

cur_path=get(cur_obj,'String')
if(~isempty(cur_path))
    winopen(cur_path);
end

```

With this solution I was able to use the same context menu for two "Edit Text" objects.