Rectangle appears on hooked graph
ChrLie
I can reproduce this behaviour with:
function DisplayImage(w)
wave w
DoWindow Image
if (V_flag ==0)
NewImage/K=1/N=Image w
SetWindow Image,hook(s)=myHook
endif
end
Function myHook(s)
STRUCT WMWinHookStruct &s
wave cube = root:cube
// store where the mouse is currently
variable xx = round ( AxisValFromPixel("", "Bottom", s.mouseLoc.h) )
variable yy = round ( AxisValFromPixel("", "Left", s.mouseLoc.v) )
variable maxX = DimSize(cube, 0)
variable maxY = DimSize(cube, 1)
switch(s.eventCode)
case 3: // handle left mouse click
// prevent error when clicking outside of image
if (xx >= maxX || yy >= maxY || xx < 0 || yy < 0)
break
endif
MatrixOp/O CrsSpec = beam(cube, xx, yy)
wave CrsSpec = root:CrsSpec
doWindow/F PointSpectrum
if (V_flag==0)
Display/K=1/N=PointSpectrum CrsSpec
endif
break
endswitch
return 0
End
wave w
DoWindow Image
if (V_flag ==0)
NewImage/K=1/N=Image w
SetWindow Image,hook(s)=myHook
endif
end
Function myHook(s)
STRUCT WMWinHookStruct &s
wave cube = root:cube
// store where the mouse is currently
variable xx = round ( AxisValFromPixel("", "Bottom", s.mouseLoc.h) )
variable yy = round ( AxisValFromPixel("", "Left", s.mouseLoc.v) )
variable maxX = DimSize(cube, 0)
variable maxY = DimSize(cube, 1)
switch(s.eventCode)
case 3: // handle left mouse click
// prevent error when clicking outside of image
if (xx >= maxX || yy >= maxY || xx < 0 || yy < 0)
break
endif
MatrixOp/O CrsSpec = beam(cube, xx, yy)
wave CrsSpec = root:CrsSpec
doWindow/F PointSpectrum
if (V_flag==0)
Display/K=1/N=PointSpectrum CrsSpec
endif
break
endswitch
return 0
End
Then execute
Make/U/B/N=(200,200,200) cube = abs(enoise(1))
MatrixOP/O M_SumImage = sumBeams(Cube)
DisplayImage(M_SumImage)
MatrixOP/O M_SumImage = sumBeams(Cube)
DisplayImage(M_SumImage)
It may take 30-40 clicks to get it, but it occurs. This is under Mac OS 10.8.5 and IGOR 6.34A.
Is there something in my code that may cause this or possibly a bug?
EDIT: This does not seem to be an issue on Windows and on Mac it seems to be more likely to occur when I first increase the image by dragging the graph window to a larger size
Try doing one of these things from your hook function when you want the click that your hook function handles to not be used for its normal purpose, which might be starting a marquee:
1. Return 1 from your hook function. This tells Igor that your hook function handled the click and that the click should not continue to be handled by the event system.
2. Call
GetMarquee/W=$(s.winName) 0, 0, 0, 0
. This will clear any marquee that is on the graph already.I don't think #2 will actually solve your problem, however, since the click is probably used to start a marquee after your hook function runs.
You might also change your hook function to require more than just a click so that you don't prevent the regular Igor features such as marquee generation from being possible. For example, you could require a shift-click in the graph by only handling the event when
s.eventMod & 0x02
is true.April 4, 2014 at 06:04 am - Permalink
I think that does it! Lots of clicking - no marquee!
I thought about this but wasn't sure how to do it. Might change it now!
Thanks for the quick support!!
April 4, 2014 at 06:23 am - Permalink