Selecting Objects - Strange Behaviour

cemccourseware shared this question 3 months ago
Answered

I have 3 line segments and I'd like to be able to tell which one the user has selected. I have placed code in the "On Click" for each line segment, which works as expected when the user clicks on the segments.

However, if the user "clicks-moves the mouse away a little-releases" then the line segment appears to be selected (as shown by the highlighting), but the "On Click" code is not called.

How can I track which line segment is selected/highlighted? Alternative solutions?

Comments (5)

photo
1

OnClick (event) and "selected" (status/property) is not the same. But OnClick implies the selection of the object. But also without OnClick an object can be selected.

It is possible to set or delete the status "selected" for an object whit script but (oddly) not to query it. This neither in GGB-script nor in Java-script.

I don't know any alternatives (to query "selected")

Too bad.

photo
1

What's your overall aim?

photo
1

My end game is this app here: https://www.geogebra.org/m/hjjdappw

Notice how the pointer indicating the selected line moves when you click between the lines. But if you do the "click-drag" on a line, it highlights as selected without the pointer moving. Nor does the code recognize that you have selected that line.

photo
1

You can register a clientListener in JavaScript to get notified when objects are selected. Demo https://test.geogebra.org/~...

photo
1

I don't see any clientListener in the attached Demo. Where should I be looking for an example on how to do this?

photo
© 2019 International GeoGebra Institute