MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Uživatelský manuál Strana 295

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 408
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 294
Writing Event Handlers
7-9
function myclick(varargin)
disp('Single click function')
function my2click(varargin)
disp('Double click function')
function mymoused(varargin)
disp('You have reached the mouse down function')
disp('The X position is: ')
varargin(5)
disp('The Y position is: ')
varargin(6)
You can use the same event handler for all the events you want to monitor
using the cell array pairs. Response time will be better than using the callback
style.
For instance
h = actxcontrol('SELECTOR.SelectorCtrl.1', [0 0 200 200], f, ...
{'Click' 'allevents'; 'DblClick' 'allevents'; ...
'MouseDown' 'allevents'})
and allevents.m is
function allevents(varargin)
if (varargin{2} = -600)
disp ('Single Click Event Fired')
elseif (varargin{2} = -601)
disp ('Double Click Event Fired')
elseif (varargin{2} = -605)
disp ('Mousedown Event Fired')
end
Note MATLAB does not support event arguments passed by reference or
return values from events.
Zobrazit stránku 294
1 2 ... 290 291 292 293 294 295 296 297 298 299 300 ... 407 408

Komentáře k této Příručce

Žádné komentáře