Prevent dragging axis with mouse

Hi!

I have a rather specific issue - in my code I am using two (four) draggable lines to select a ROI. Now I have the problem that the starting position of these lines is at the graph region borders, which means if one is not careful enough one can accidentally drag the axis instead of that line, which is not especially user friendly ...

Therefore is it possible to somehow prevent axis dragging to a new position?

Thanks,
Gregor
Are you using a Window Hook function to drag the lines? If so, you should be able to return 1 from you hook function when you get a mouse event, and that will prevent Igor from using the event.

You might consider instead using two cross-hair free cursors or the graph marquee to define your rectangular ROI.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
johnweeks wrote:
Are you using a Window Hook function to drag the lines? If so, you should be able to return 1 from you hook function when you get a mouse event, and that will prevent Igor from using the event.


No I am using the same solution as is written by you guys in "Image Line Profiles" (i.e. SetFormula looking at the S_TraceOffsetInfo string). I could try to rewrite everything as a hook function - I do not want to use the solution with the cursors ...

So if I understand correctly if there is a hook function returnig 1 there is no way to be able to drag the axis?

--
Gregor Kladnik
ALOISA beamline @ Elettra synchrotron
I think my advice was not so good :)

Trying to do what you're doing using mouse events in a hook function would be very tricky. The only advantage would be that you can return 1 from a hook function to tell Igor that you handled the event and that Igor shouldn't do anything further. That would prevent the mouse clicks/drags from affecting the axis.

One possibility that occurs to me now is to use free axes and position them somewhat away from the plot area. That might give you the room you need to avoid landing on the axes.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Thanks John for all the comments. I was also considering free axes but opted against them ... I think I will leave it like I have coded it now since there is no straightforward solution that suits my needs ...

Maybe this "fix axis position" could be a request for IGOR 7 as a new option in ModifyGraph for axes? :)

Cheers,
Gregor
--
Gregor Kladnik
ALOISA beamline @ Elettra synchrotron
Just my two cents, but wouldn't it be best to avoid this problem all together? I think there are other problems involved (the user not realizing that there are drag-able lines, difficulty to grab the lines with the mouse from the edge) and having ROI lines fully at the edge or almost at the edge is most often not necessary (why have them at all in this case). Would it be an option to initialize the lines some percentage distance away from the axis, so that the user can easily interact with them without the fear of dragging the axes instead? I usually use like 10% of the graph space for these cases. Also, an additional SetVariable option to precisely set the lines but also to get them away from the axes is usually an user-friendly way to do this.
chozo, thanks for all the input!

chozo wrote:
I think there are other problems involved (the user not realizing that there are drag-able lines, difficulty to grab the lines with the mouse from the edge) and having ROI lines fully at the edge or almost at the edge is most often not necessary (why have them at all in this case).


I have set up the code in such a way that the mouse cursor changes its shape when it is close enough to the line to be dragged around as well as the lines are easily distinguishable from the data (2D data in black and white the lines in bright green). It is necessary to set the initial value at the border since the default value one is interested in is all the data (i.e. whole q range of the 2D wave data).

chozo wrote:
Also, an additional SetVariable option to precisely set the lines but also to get them away from the axes is usually an user-friendly way to do this.


Indeed I am using also this option as a read-out of the set value as well as being able to set the value independently from draging the lines (i.e. setting up the ROI).

--
Gregor Kladnik
ALOISA beamline @ Elettra synchrotron
johnweeks wrote:
Trying to do what you're doing using mouse events in a hook function would be very tricky. The only advantage would be that you can return 1 from a hook function to tell Igor that you handled the event and that Igor shouldn't do anything further. That would prevent the mouse clicks/drags from affecting the axis.


Following your advice I have written a hook function for dragging around a line (represented by a wave) and now everything works as I wanted, i.e. one cannot move/drag the axis anymore.

Thanks John for your help!

--
Gregor Kladnik
ALOISA beamline @ Elettra synchrotron