First you need to declare your shape as a handle:
fig = figure;
then you can set the properties (in quotation marks below) to activate the functions you wrote to respond to user interactions (using the @ signs):
set(fig,'KeyPressFcn',@keyDownListener) set(fig, 'KeyReleaseFcn', @keyUpListener); set(fig,'WindowButtonDownFcn', @mouseDownListener); set(fig,'WindowButtonUpFcn', @mouseUpListener); set(fig,'WindowButtonMotionFcn', @mouseMoveListener);
In the above example from shooter03.m there is a space shooter MATLAB, an excellent source (from the Matlab file exchange) for many aspects of the interaction of user objects in MATLAB:
http://www.mathworks.com/matlabcentral/fileexchange/31330-daves-matlab-shooter/content/shooter03/shooter03.m
source share