function theResult = doubleclick % doubleclick -- Trap for double-clicks. % doubleclick (no argument) returns TRUE if a click % is detected while "doubleclick" itself is executing; % otherwise, FALSE. Call "doubleclick" at the top % of a "WindowButtonDown" or "ButtonDown" callback. % The 'Interruptible' property of the callback-object % must be 'on'. The double-click time is 0.5 sec. % A valid double-click causes two values to be returned % in succession: first, a logical(1), then []. The % latter can be ignored; it represents the first click % that initiated the process. For a valid single-click, % only logical(0) is returned. % Copyright (C) 1997 Dr. Charles R. Denham, ZYDECO. % All Rights Reserved. % Disclosure without explicit written consent from the % copyright owner does not constitute publication. % Version of 25-Jul-1998 09:47:16. % Updated 21-Oct-1998 10:14:18. global CLICK_COUNT % Use "persistent in Matlab 5.2+. % Increase the following if the % double-click-time seems too short. DOUBLE_CLICK_TIME = 1/2; % Seconds. if isempty(CLICK_COUNT), CLICK_COUNT = 0; end CLICK_COUNT = CLICK_COUNT + 1; if CLICK_COUNT == 1 tic while isequal(CLICK_COUNT, 1) & toc < DOUBLE_CLICK_TIME, end end drawnow % Process the event-cue. % Note: % Despite the "drawnow" seen above, Matlab does not % update the "SelectionType" in timely fashion, so % it cannot be used to trap a double-click properly. result = (CLICK_COUNT > 1); CLICK_COUNT = []; if nargout > 0 theResult = result; else disp(result) end