Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: [Q] CallBack Problem
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Paulo Alexandre Silva

Posts: 3
Registered: 12/7/04
[Q] CallBack Problem
Posted: Aug 30, 1996 5:33 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have this label in a figure :

Hmenu(2)=uimenu(Hmenu(1),'Label','Search Window'...
,'CallBack', ['OUT=cur;']);

The function CUR shows the coordenates of mouse and other information.

When I use the function CUR from MATLAB commmand windown no problem,
when I execute the label I can´t see the coordenates and CUR return

I don´t understand where is the problem ????

----------------------------- CUR.M ---------------------------
function out=cur(arg)

%CUR Show x-y Coordinates Using Mouse.
% CUR places the x-y coordinates of the mouse in the
% lower left hand corner of the current 2-D figure window.
% When the mouse is clicked for the second time ,the coordinates are erased.
% XY=CUR returns XY=[x,y] coordinates displayed when mouse was clicked.
% Returns XY=[] if a key is pressed.

% Paulo da Silva
% 28-8-96

global XY_OUT_ XY_FIRST_

if ~ni, arg='i'; end
if arg(1)=='i'
if isempty(Hf), error('No Figure Available.'),end
if isempty(Ha), error('No Axes in Current Figure.'),end
if any(get(Ha,'view')~=[0 90]), error('Plot must be 2D'); end

'Position',[1 1 280 15],...
set(Hf, 'Pointer','crossh',...

figure(Hf) % bring figure forward

if nargout % must return x-y data
key=waitforbuttonpress; % pause until mouse is pressed
if key,
out=[]; % return empty if aborted
cur('e') % clean things up
XY_FIRST_=XY_OUT_; % get first point
key=waitforbuttonpress; % pause until mouse is pressed
if key,
out=[]; % return empty if aborted
cur('e') % clean things up
out=[XY_FIRST_; XY_OUT_]; % now that move is complete return points

elseif arg(1)=='m' % mouse is moving, return x,y coordinates
cp=get(gca,'CurrentPoint'); % get current mouse position
xystr=sprintf('[x=%.3g, y=%.3g, xdim=%.3g, ydim=%.3g]',2*XY_OUT_,2*(XY_OUT_-XY_FIRST_));
set(Hu,'String',xystr) % put x-y coordinates in text box

elseif arg(1)=='e' % mouse click occurred, clean things up
delete(get(gcf,'Userdata')) % delete text box
'Userdata',[]) % clean up figure
set(gca,'Userdata',[]) % clear xy data


/"\|/"\|/"\|/"\ Paulo Alexandre Ferreira da Silva <=> l38208@alfa.ist.utl.pt
< P | A | F | S >
\_/|\_/|\_/|\_/ Technical Superior Institute of Lisbon
/ \ / \ / \ / \ Electronics & Computers Engeneering
" ~ " ~ " ~ " ~ "

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2016. All Rights Reserved.