2
$\begingroup$

is there a way to DISABLE the ability to remove points with ALT-click (APPLE-click) from a locator pane? I'm writing a code that allows users to manually label objects in an image by connecting two consecutive points by a line. When the user is able to remove an arbitrary point from within the list, the connections between the points get messed up. Consider this snippet:

pts = {{0, 0}, {1, 1}};
LocatorPane[Dynamic[pts], 
Dynamic[Graphics[Line[{#[[1]], #[[2]]}] & /@ Partition[pts, 2]]], 
LocatorAutoCreate -> All]
$\endgroup$
0

1 Answer 1

2
$\begingroup$

Points can be created by Mouse click alone, but deleted only with Click + Alt, so we can capture MouseClicks and pass them to LocatorPane only if Alt is not pressed.

EventHandler[#, {"MouseClicked" :> {}}, 
                PassEventsDown -> Dynamic[! CurrentValue["AltKey"]]
            ] &[

 LocatorPane[Dynamic[pts], 
  Dynamic[Graphics[Line[{#[[1]], #[[2]]}] & /@ Partition[pts, 2]]], 
  LocatorAutoCreate -> All]

]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.