.on_mouse_click()- function
Dear all,
I am struggling getting my old code-snippet to work in OS v3.2. Thus my question: Does the function .on_mouse_click() still work in the new OS version?
I have two empty text input fields. My aim is to set the cursor automatically in the first text input field. Participants should give their answer and press enter to confirm it. When the answer is given (var.response_A), the cursor should jump automatically into the second text input field so that participants can enter their answer in the second field and confirm it once again with enter.
This is the code-snippet which worked in the past but does not work any more in OS v3.2:
# Execute form and activate second text_input field
form._exec(focus_widget = input1)
if var.response_A != "":
input2.on_mouse_click((0,0))
Can you help me with this question?
Thanks a lot!
Best,
Sabry
Comments
Hi Sabry,
What is the error message? And what kind of object is input2?
Eduard
Hi Eduard,
well, there is no error message. I only know that the code worked in the former OS version as described above, but in the new one it does not work that way any more. Specifically, in the new OS version, one has to click with the mouse in the first text field to set the cursor there in order to enter the answer. To get the cursor in the second text field, one has to click with the mouse in the second field. Than one can press enter to confirm the answers. Object input1 and input2 are text_input widgets which I defined beforehand:
input1 = widgets.text_input(form, return_accepts=True, var=u"response_A", text= " ")
input2 = widgets.text_input(form, return_accepts=True, var=u"response_B", text= " ")
Best,
Sabry
Hi Sabry,
I think some parts of the input form has changed recently, but which exactly I don't know. Specifically, whether, the on_mouse_click function still works. Can you share (a simplified version of) your experiment here, then I'll have a look whether I can make it behave like you want it.
Best,
Eduard
Hi Eduard,
here is the very simplified version. Thank you a lot!
Best,
Sabry
Hi Sabry,
looking at the code, I realize that this code can't work, really. Once a formed is executed you can't change settings inside the form without executing the form again. So after your call
form._exec(), the focus can't be changed anymore. But maybe I am also misunderstanding the problem. I realize it would be more useful to see the behaviour in the old version. Anyway, from looking at the github code for thison_mouse_click()function, it seems that it is not defined for text input widgets. So, bad news I guess.Sorry.
Eduard
Anyway - thanks for your effort, Eduard!
Best,
Sabry