From: Jan Simon on 14 May 2010 14:58 Dear Urs! > > Dear Doug! > > How can I get the screen coordinates for docked figures? > > Jan > my snippet (see above) works for docked figs as well... > urs Yes, but Doug's hint to OVEROBJ calls: p = get(0, 'PointerLocation'); figPos = get(fig, 'Position'); This fails for a docked figure, doesn't it? Are there any workarounds? Jan
From: us on 14 May 2010 15:11 "Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hsk6ft$ojr$1(a)fred.mathworks.com>... > Dear Urs! > > > > Dear Doug! > > > How can I get the screen coordinates for docked figures? > > > Jan > > > my snippet (see above) works for docked figs as well... > > urs > > Yes, but Doug's hint to OVEROBJ calls: > p = get(0, 'PointerLocation'); > figPos = get(fig, 'Position'); > This fails for a docked figure, doesn't it? > Are there any workarounds? > > Jan hmm... but the (undoc) OVEROBJ works in docked figs as well, at least in r2010a... fh=@(varargin) disp(sprintf('%g',overobj('axes'))); plot(1:10); set(gcf,'windowbuttonmotionfcn',fh); % hover % dock the fig % hover, again... most likely, though, i don't understand the problem... urs
From: Jan Simon on 14 May 2010 15:33 Dear Urs! > hmm... but the (undoc) OVEROBJ works in docked figs as well, at least in r2010a... > fh=@(varargin) disp(sprintf('%g',overobj('axes'))); > plot(1:10); > set(gcf,'windowbuttonmotionfcn',fh); > % hover > % dock the fig > % hover, again... > > most likely, though, i don't understand the problem... The problem is easy to describe: Matlab 2009a. There OVEROBJ fails for docked figures: The correct object cannot be found, because the position of docked figures in pixels is [1, 1, Width, Height] ever and the absolute screen position cannot be determined. Jan
From: Nick Stokes on 14 May 2010 18:17 @us > well... > firstly, some replies have NOT been sarcastic at all... > second, NOW things seem more clear as you explain them in better MLbbers terms, > because the way you first phrased it, CSSMers got the impression that you don't > want to use the mouse AT ALL... I still don't understand why and how come you can talk for everyone else in the list with such certainty, but anyhow... > to achieve the above demonstrated functionality, look at this callbacks > set(gcf,'windowbuttonmotionfcn',@your_callback); > % eg, > plot(1:10); > fh=@(varargin) disp(sprintf('%d %d',get(gcf,'currentpoint'))); > set(gcf,'windowbuttonmotionfcn',fh); > % now, move your mouse and look at the command window... This is useless!! None of this code tells anything about what OBJECT is under the currentpoint! Of course we'd be implementing 'windowbuttonmotionfcn' at some point for the interactive example I'd posted, but that is totally irrelevant. > % your callback would be more intelligent, of course... yes! and I tried to spare you all this when I was asking the question to begin with. Now hopefully that we are on the same page, and now that we have the cursor position via get(gcf,'currentpoint') in some kind of callback or whatever, let's move on: How do I determine which object is at that point? And, although interesting thought (and thanks for posting earlier), we do not want to call the "robot" to do the clicking because (1) it is not elegant (2) we don't want to update figure's currentobject (3) it doesn't answer the question. (and please, please, do not answer if you don't know the exact answer to this. spare me the irrelevant) @ "Doug Schwarz' > Perhaps you can modify overobj.m to do what you want. This was a good lead! Thank you. But it seems to work only for objects that are immediate children of a figure. In particular, it is a simplistic code that checks for bounding box of the objects, and determines whether current point is underneath. Probably very useful for UI, but not general line, patch, etc.. (no bounding box trick will work there).
From: dpb on 14 May 2010 18:28
Nick Stokes wrote: .... > (and please, please, do not answer if you don't know the exact answer > to this. spare me the irrelevant) .... OK, I'll do so instead... :) Have you considered it just simply may not be possible to a user app in Matlab and that ML internals are available to ML itself in an obviously much more intimate manner than at the m-file level? -- |