Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Disabling "enter" button in form_text_input

Hello,
I have a very basic question but unfortunately, I couldn't manage to make it :( In my experiment, I am using form_text_input. I want my participants to write a memory, which can be long and include many sentences and paragraphs. But in the form, whenever they press the "enter" button the page is changing and the next task appears. As you know pressing the enter is very reflexive in our lives and even if I told them not to press they press :( So is there a possibility to disable this function or at least changing it with any other rarely used button.

Comments

  • Hello again :) Actually I found to disable this function by return_accept option. However I still have one problem about the same issue. In the text input form, I added a "next" button. But the button is not active until the enter pressed. I want my participants whenever they finished writing they are able to click the next button and skip the task. Since my experiment is a bit long, it is hard to inform them " please first press the enter and then click the next button". Is it possible to activate next button starting from the experiment?

  • Hi,

    That is weird. When I add a button to a form, in can be clicked always, no need to press or alike. Are you sure you're doing it correctly? Can you share the code of your form?

    Tjhanks,

    Eduard

  • Hello Eduard,
    Here is my code for text document. It is actually very basic, I just added a button at the end. Even if I give a limited tome for the presentation the situation is not changing.

    set timeout infinite
    set spacing 10
    set rows "1;1;6;1;1"
    set only_render no
    set ok_text Devam
    set margins "50;50;50;50"
    set form_var response
    set form_title Title
    set form_question "haydi evini anlat"
    set cols 1
    set _theme gray
    widget 0 0 1 1 label text="[form_title]"
    widget 0 1 1 1 label center=no text="[form_question]"
    widget 0 2 1 1 text_input focus=yes return_accepts=no stub="" var="[form_var]"
    widget 0 4 1 1 button center=yes frame=yes text="[ok_text]"

  • Hi,

    your code works for me. What version of Opensesame are you using? Which backend? Which operating system? I'm on Ubuntu 16.06, OS 3.2.2 with xpyriment backend.

    Eduard

  • "I want my participants whenever they finished writing they are able to click the next button and skip the task."
    I am facing the same issue. Only after I press enter, I am able to use the button.

  • Hello,
    I am having a similar issue. My experiment contains a form with open text input, which may contain more than one line and when the user presses Enter, they are directed to the next page.
    Solution to moving next page is as Ece told adding "return_accepts=no", but how can I manage to go to the next line.
    When the users want to input more than one line (such as listing some thing), how can I manage it?

  • If it happens that often, it sounds like a bug.

    What version of Opensesame are you using? Which backend? Which operating system?

    Can you provide this information?

    @sebastiaan: Have you seen this before?

    Eduard

  • Hi guys,

    There seem to be a few issues in this discussion.

    The first is that @akca_ece reports needing to press enter to be able to click on the Accept button. This was indeed true with OpenSesame 3.1 and earlier, but as of 3.2 you can use all widgets at the same time; that is, you can click on the accept button without needing to leave the text input. So upgrade!

    The second, pointed out by @newbee , is that you cannot use enter to go to the next line. This is indeed not possible. The only way that I can think of is by monkey-patching the way that the text_input widget handles key presses. You can do this by entering the following script in the Prepare phase of an inline_script at the very beginning of the experiment. This is hacking into the internals of OpenSesame, though, so it might break in future versions!

    Cheers!
    Sebastiaan

    def my_coroutine(self):
    
        self.caret_pos = len(self.text)
        retval = None
        while True:
            d = yield retval
            retval = None
            if d[u'type'] == u'stop':
                break
            if d[u'type'] != u'key':
                continue
            key = d[u'key']
            if not self._key_filter(key):
                continue
            if key == u'space':
                self.text = self.text[:self.caret_pos] + u' ' \
                    + self.text[self.caret_pos:]
                self.caret_pos +=1
            elif key == u'backspace':
                self.text = self.text[:self.caret_pos-1]  \
                    + self.text[self.caret_pos:]
                self.caret_pos = max(0, self.caret_pos-1)
            elif key == u'delete':
                self.text = self.text[:self.caret_pos] \
                    + self.text[self.caret_pos+1:]
            elif key in (u'return', u'enter'):
                if self.return_accepts:
                    retval = self.text
                else:
                    self.text += u'\n'
                    self.caret_pos += 1
            elif key in (u'home', u'page up'):
                self.caret_pos = 0
            elif key in (u'end', u'page down'):
                self.caret_pos = len(self.text)
            elif key == u'left':
                self.caret_pos = max(0, self.caret_pos-1)
            elif key == u'right':
                self.caret_pos = min(len(self.text), self.caret_pos+1)
            elif len(key) == 1:
                self.text = self.text[:self.caret_pos] + key \
                    + self.text[self.caret_pos:]
                self.caret_pos +=1
            self._update()
            self.set_var(self.text)
    
    
    from libopensesame import widgets
    widgets.text_input.coroutine = my_coroutine
    

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

  • Hello all,
    Thanks @sebastiaan and @eduard,
    The hack worked in my case, I added this script at the beginnning of my experiment in prepare phase.
    And now it is working as desired. When I want participants to write long texts and make lists, hitting Enter takes them to the next line instead of next page (when return_accepts=False).
    My OpenSesame version: 3.2.5

Sign In or Register to comment.