GUI Examples #10:Explore mouse pointer manipulation

December 13, 2009 by Matt Fig 
Filed under: GUI, Tutorials 
Leave a Comment
VN:F [1.8.8_1072]
Rating: 0 (from 0 votes)
VN:F [1.8.8_1072]
Rating: 10.0/10 (1 vote cast)

Pushing the pushbutton to  close the GUI proves to be very difficult! :lol:

GUIExample10

function [] = GUI_10()
% Demonstrate how to control the mouse pointer from a GUI.
% Just for fun, show how to manipulate the mouse pointer.  To close the 
% figure, use the regular window x in the upper right corner.
% Note, I have had reports that nothing happens when this is run on Mac
% computers.
%
% Author:  Matt Fig
% Date:  7/15/2009
 
S.fh = figure('units','pixels',...
 'position',[300 300 300 160],...
 'menubar','none',...
 'name','GUI_10',...
 'numbertitle','off',...
 'resize','off');
S.UN = get(0,'units')% We need to temporarily change this.
S.pb = uicontrol('style','push',...
 'units','pix',...
 'position',[20 30 260 100],...
 'string', 'Push Me To Close Figure',...
 'fontsize',12,'fontweight','bold',...
 'callback',{@pb_call,S});
set(S.fh,'WindowButtonMotionFcn',{@fh_wbmf,S})          
 
function [] = fh_wbmf(varargin)
S = varargin{3}% Get the structure.
set(0,'units','normalized') % Temporary, see below.
% Move the mouse pointer to a random position.
set(0, 'PointerLocation', [rand rand])  
set(0,'units',S.UN)  % Undo change to user's system.  Good courtesy.
VN:F [1.8.8_1072]
Rating: 10.0/10 (1 vote cast)
VN:F [1.8.8_1072]
Rating: 0 (from 0 votes)
GUI Examples #10:Explore mouse pointer manipulation10.0101

Popularity: 1% [?]

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Live
  • PDF
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
  • Add to favorites
  • email
  • MySpace
  • RSS

Related Posts

Comments

Comments are closed.