Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB: Modify getline() to remove 'end input on double-click' functionality

The matlab function getline (image processing toolbox) returns the position of a polyline (which has previously been defined with the cursor) either on a double-click or on pressing the return key or spacebar.

Due to my butter-fingers and accidentally double-clicking I want to remove the ability to end on a double-click.

What part do I need to change, or what functions should I be looking out for, I can't find out how a double click is even defined in matlab.

Cheers!

like image 694
Tom Avatar asked Nov 29 '25 23:11

Tom


1 Answers

MATLAB associates "callback" functions with graphics objects, which define what to do when the mouse is clicked, keys are pressed, etc.. In getline(), the section to look at is the NextButtonDown() subfunction. This is the callback that is associated with subsequent mouse presses after the first mouse press to initiate the line. The key is that is checks the SelectionType figure property, which will be open for a double click. When that is the case, it closes the figure. So, to disable that functionality, just remove the extra case and checking logic. Here is the diff for my r2009b version:

306,310d305
< selectionType = get(GETLINE_FIG, 'SelectionType');
< if (~strcmp(selectionType, 'open'))
<     % We don't want to add a point on the second click
<     % of a double-click
< 
322,328d316
<     
< end
< 
< if (~strcmp(get(GETLINE_FIG, 'SelectionType'), 'normal'))
<     % We're done!
<     set(GETLINE_H1, 'UserData', 'Completed');
< end
like image 51
John Colby Avatar answered Dec 01 '25 21:12

John Colby