Use all 4 SelectionType options in a ButtonDownFcn callback?

8 views (last 30 days)
I'm doodling with a gui where I would like to use all four "SelectionType" posibilities to select different responses to the button selection ofthe users. Somehow I cannot manage to get a clean single use of the "open" selectiontype. With the function below set to the buttondownfcn of an axes, I cannot manage to get a single evaluation of the "open" option by double clicking. Either I get the "normal" output before (ptime = 0) or after (ptime = 0.3), that is not what I wanted. Does anyone have an example to show how this is supposed to be done?
Example function:
function seltest(ptime)
point1 = get(gcf,'CurrentPoint');
seltype = get(gcf,'SelectionType')
pause(ptime)
switch seltype
case 'alt'
disp(['ALT: ',datestr(clock,'HH:MM:SS.FFF')])
case 'extend'
disp(['EXTEND: ',datestr(clock,'HH:MM:SS.FFF')])
case 'normal'
disp(['NORMAL: ',datestr(clock,'HH:MM:SS.FFF')])
case 'open'
disp(['open: ',datestr(clock,'HH:MM:SS.FFF')])
otherwise
disp(['VERY ODD: ',datestr(clock,'HH:MM:SS.FFF')])
end
This is then tested with:
figure,set(gca,'buttonDownFcn',@(src,event) seltest(0))
and then clicking away, followed by:
set(gca,'buttonDownFcn',@(src,event) seltest(0.2))
This is one typical outcome:
>> set(gca,'buttonDownFcn',@(src,event) seltest(0.2))
>> seltype =
normal
seltype =
open
open: 20:22:19.773
NORMAL: 20:22:19.907
A single run through the "open" case is what I hoped for here.
  2 Comments
Walter Roberson
Walter Roberson on 27 Jan 2014
I am not sure why the pause() is there considering that you are checking seltype before the pause() rather than after?
Bjorn Gustavsson
Bjorn Gustavsson on 28 Jan 2014
Good suggestion. That worked better - but I still get two "open", and the function runs twice. It's tolerable but not what I'd like to see - if a double click is one "open" event then I'd like the function to run once afte that, not twice. One possibility is that I'm motorically challenged and can't double-click, but I've managed OK this far.

Sign in to comment.

Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!