Bug: Mouse click is evaluated twice

Sander Tacker shared this problem 3 months ago
Not a Problem

If a click on a button causes an input bar to appear exacly at the mouse position, the mouse click is evaluated twice and the input bar gets selected.

How can I deselect the input bar? The command SelectObjects() doesn't work since the second evaluation of the mouse click happens after the execution of the script. See attachment.

Please don't suggest to move my button away. For my purpose it has to be "under" the input bar.

GeoGebra Classic 5.0.587.0-d / Windows 10

Comments (12)

photo
1

Does it work better if you do

SetValue(ShowInput1, true)
instead of

ShowInput1 = true

photo
1

No, that makes no difference.

The problem is that buttons in GeoGebra seem to react on the MouseDown-Event whereas input bars are activated on the MouseUp-Event. I think, any change to the OnClick handler of the button won't have an effect, because the input bar gets activated afterwards.

Its a bit annoying und for users unexpected: In my real applet, there are several input bars and it's confusing for the user why a certain input bar gets activated cause it looks like a hint to type there first.

Do you see another way to avoid this behaviour?

photo
1

You could try making selection allowed false then true. Use SetFixed()

photo
1

Thank you for your suggestion, but it doesn't work: The undesired activation of the input bar occurs AFTER the execution of the button's OnClick-Script, so where should I make selection allowed again?

photo
1

Hi Michael, this looks like a good idea, but it also doesn't work. I implemented it, but it generally seems like GeoGebra doesn't support the setTimeout function at all, see simple attachment.

photo
1

Try online

photo
photo
1

Why JS..?

photo
1

Well, you successfully disabled the input bar, but where do you enable it again so the user can use it after clicking the "show"-button?

photo
photo
1

workaround

create a polygon like button instead

you can use a text like button also

Files: foro.ggb
photo
1

Hi mathmagic,

thanks, that finally works!

Speaking about design aspects, it would be nessecary to replace all my buttons by single text fields and polygons that dynamically fit the size of the text fields since my buttons captions are changing in my applet.

photo
photo
1

I was tinking in substituting all buttons by only texts, I do not know how to change the length of text with captions because I do not know how to get the length or value of a caption; but..... if the caption comes from a value the text can be the value of text like ""+nameofvalue

an example can help

© 2020 International GeoGebra Institute