From: Corey Kelly on
Walter Roberson <roberson(a)hushmail.com> wrote in message <48kKn.74810$0M5.25007(a)newsfe07.iad>...
> Corey Kelly wrote:
>
> > So I've managed to get the stack to play properly, and now I'm working
> > on grabbing the mouse coordinates. ginput() makes sense, but I'm not
> > sure how to go about calling the function. Does the function directly
> > return the coordinates when called?
>
> Yes, it does.
>
> > I'm trying something like this:
> >
> > % --- Executes on mouse press over axes background.
> > function axes1_ButtonDownFcn(hObject, eventdata, handles)
> > handles.coords = [handles.coords ginput(1)];
> > guidata(hObject, handles);
>
> When you are within a button down callback, get(hObject, 'currentpoint')
> will return the coordinates (but cross-check the units). You do not
> want to use both ginput and a button down callback.
>
> > but clicking on the axes doesn't seem to do anything. I've tried
> > print(handles.coords) and I've been playing around with the HitTest
> > options, but can't seem to get the function to do anything.
>
> If you are using a button down callback at the axis level, then you want
> to set HitTest off on all children of the axis.
>
> set(findall(gca, '-property', 'HitTest'), 'HitTest', off)

Thanks again for your help. Where in my code should I be setting the HitTest option? I've got it in the OpeningFcn, but it doesn't seem to be doing the trick. I'm getting

??? Undefined function or variable 'off'.

I've tried setting the axes HitTest to off using GUIDE, and changing my button down callback to

% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
get(hObject, 'currentpoint')

so I can monitor the output in the command window, but nothing is happening when I click on the image.
Sorry about having so many questions. This GUI business is really confusing me.
From: Walter Roberson on
Corey Kelly wrote:
> Walter Roberson <roberson(a)hushmail.com> wrote in message

>> set(findall(gca, '-property', 'HitTest'), 'HitTest', off)
> Where in my code should I be setting the
> HitTest option? I've got it in the OpeningFcn, but it doesn't seem to be
> doing the trick. I'm getting
>
> ??? Undefined function or variable 'off'.

Sorry, off should be quoted in the code, 'off'

You do not want to set this in your OpeningFcn: you want to set this
after you have created your axis and plot objects.

> I've tried setting the axes HitTest to off using GUIDE, and changing my
> button down callback to
> % --- Executes on mouse press over axes background.
> function axes1_ButtonDownFcn(hObject, eventdata, handles)
> get(hObject, 'currentpoint')
>
> so I can monitor the output in the command window, but nothing is
> happening when I click on the image.

The image is being hit instead; that's why you need the set()
From: Corey Kelly on
Walter Roberson <roberson(a)hushmail.com> wrote in message <R2lKn.14850$Gx2.11388(a)newsfe20.iad>...
> Corey Kelly wrote:
> > Walter Roberson <roberson(a)hushmail.com> wrote in message
>
> >> set(findall(gca, '-property', 'HitTest'), 'HitTest', off)
> > Where in my code should I be setting the
> > HitTest option? I've got it in the OpeningFcn, but it doesn't seem to be
> > doing the trick. I'm getting
> >
> > ??? Undefined function or variable 'off'.
>
> Sorry, off should be quoted in the code, 'off'
>
> You do not want to set this in your OpeningFcn: you want to set this
> after you have created your axis and plot objects.
>
> > I've tried setting the axes HitTest to off using GUIDE, and changing my
> > button down callback to
> > % --- Executes on mouse press over axes background.
> > function axes1_ButtonDownFcn(hObject, eventdata, handles)
> > get(hObject, 'currentpoint')
> >
> > so I can monitor the output in the command window, but nothing is
> > happening when I click on the image.
>
> The image is being hit instead; that's why you need the set()


It seems like every solution is making me more aware of how little I know. Should I be explicitly creating my axis object at some point? I think my use of GUIDE has hidden some functionality from me. I know the axis is there because it is displaying my images, but I can't find any call to a CreateFcn for the axis.
From: Corey Kelly on
Walter Roberson <roberson(a)hushmail.com> wrote in message <R2lKn.14850$Gx2.11388(a)newsfe20.iad>...
> Corey Kelly wrote:
> > Walter Roberson <roberson(a)hushmail.com> wrote in message
>
> >> set(findall(gca, '-property', 'HitTest'), 'HitTest', off)
> > Where in my code should I be setting the
> > HitTest option? I've got it in the OpeningFcn, but it doesn't seem to be
> > doing the trick. I'm getting
> >
> > ??? Undefined function or variable 'off'.
>
> Sorry, off should be quoted in the code, 'off'
>
> You do not want to set this in your OpeningFcn: you want to set this
> after you have created your axis and plot objects.
>
> > I've tried setting the axes HitTest to off using GUIDE, and changing my
> > button down callback to
> > % --- Executes on mouse press over axes background.
> > function axes1_ButtonDownFcn(hObject, eventdata, handles)
> > get(hObject, 'currentpoint')
> >
> > so I can monitor the output in the command window, but nothing is
> > happening when I click on the image.
>
> The image is being hit instead; that's why you need the set()


It seems like every solution is making me more aware of how little I know. Should I be explicitly creating my axis object at some point? I think my use of GUIDE has hidden some functionality from me. I know the axis is there because it is displaying my images, but I can't find any call to a CreateFcn for the axis.
From: Walter Roberson on
Corey Kelly wrote:

> Should I be explicitly creating my axis object at some point? I
> think my use of GUIDE has hidden some functionality from me. I know the
> axis is there because it is displaying my images, but I can't find any
> call to a CreateFcn for the axis.

Often it is not necessary to create the axes explicitly, as the axes
will be created automatically if a handle graphics object is created
that requires an axes as a parent. For example, plot() and the various
image display calls all will create the axes automatically. You would be
unlikely to call the CreateFcn for an axes yourself: if a CreateFcn is
defined for the axes (by setting the root property DefaultAxisCreateFcn
) then it will be automatically called at the time of creation of the
axes after Matlab has internally created the handle graphics object.

I have never used an axes CreateFcn myself. I do tend to call axes()
myself to create the axes before I populate it, but I do that so as to
turn its visibility off until I have finished populating it, and to
position it, and so that I get its handle so that I can explicitly place
multiple objects on the axes without worrying that the user might have
clicked something and accidentally made that other thing the "current axes".
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11
Prev: mbuild -setup doesn't see my compiler
Next: Using imcontrast