Explore the community Forums Lectora Lectora Questions & Answers Enter and entry field

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #337097 Score: 0
    Profile photo of Mkia
    Mkia
    Member
    beginner
    intermediate
    friend finder
    contributor
    wise owl
    advanced
    curious george
    3 pts
    @Mkia

    Hi, I’m trying to figure out how to make enter functional when using entry fields. I would like a user to type an answer into the entry field, press enter and get the feedback immediately.

    Sounds simple, right? But…how can I make it work exactly like that? I’m sure I’m missing something…so heeelp?

     

     

     

     

     

    #337107 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    199 pts
    @Klaatu

    Here is a simple example of how a script can easily be used to trigger an action (in this case an action that processes a question) when the Enter key is pressed.

    By the way, the answer is sea turtles.

    😉

     

     

     

    #337110 Score: 0
    Profile photo of Mkia
    Mkia
    Member
    beginner
    intermediate
    friend finder
    contributor
    wise owl
    advanced
    curious george
    3 pts
    @Mkia

    this looks like a puzzle without the attachment…:))

    but I’m happy someone replied so fast and am looking forward to seeing this solution!!!

    #337126 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    199 pts
    @Klaatu

    Sorry about that. Let me know if you want me to break it down.

    Attachments:
    1. Sea-Turtles.zip
    #337129 Score: 1
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    199 pts
    @Klaatu

    Here’s the same thing without using jQuery. This is probably the better route in Lectora of the two I suggest.

    This post has received 1 vote up.
    #337554 Score: 0
    Profile photo of Mkia
    Mkia
    Member
    beginner
    intermediate
    friend finder
    contributor
    wise owl
    advanced
    curious george
    3 pts
    @Mkia

    Hey Darrel, thank you!!…but I don’t see how sea turtles 2 are working without jQuery…and I couldn’t make it work on my frame.

    I guess I’m missing something…probably jQuery knowledge…:))) so I have to try it one more time…but if you have advice how to do it without jQuery that would be really really great!!…

    however… if you have advice how to do it without jQuery that would be really really great!!…

     

    <3!!

     

     

    #337572 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    199 pts
    @Klaatu

    I’m so sorry. I Didn’t mean to drag this out. Just in case for some reason I still can’t get it right and the post does not work here is the whole thing explained.

    Add this script to the page (on show run javascript) that has the entry box you want the enter key to work with.

    var thePage = document.getElementById(“pageDIV”);

    thePage.addEventListener(“keyup”, function(e){
         if(e.which == 13) {
            action72();
       }
    });
    The first line (var thePage = document.getElementById(“pageDIV”);) creates a variable called ‘thePage’ and assigns the HTML element with the ID ‘pageDIV’ to it. This happens to be the entire page. So in short, thePage equals the page.

    Starting on the second line, we add an event listener that will constantly assess whether a key has been let up from the down position (this must mean it was pressed). When it senses any key up happen, it fires off the attached function. The function brings in what triggered it as “e”. It is a simple if/then conditional that checks to see if the key up is equal to 13. Thirteen is the ASCII keycode for the enter key. If the key up is the Enter key then it fires off action 72 which is the ID of the lectora action that processes the question.

    No jQuery or other HTML extension necessary.

    #337575 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    199 pts
    @Klaatu

    Almost forgot, PageDIV will work for you, however,  the action may have a different assignment other than action72.

    #337611 Score: 2
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    303 pts
    @timk

    You could use a standard “On: Keystroke” action. This way you wouldn’t need any external JS.

    This post has received 2 votes up.
    Attachments:
    1. SeaTurtlesNoJS.zip
    #337626 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    199 pts
    @Klaatu

    Absolutely go with Tim’s offering. Placing an action on the page itself will give you the keystroke action ability. Like he said, you won’t have to use JS at all. Trivantis should make a sheet that shows all objects and what actions you can use for each. If it’s out there somewhere someone please point me in the right direction; I don’t see it in the user guide.

    Of course it would be nice to have all actions available to all objects but that’s where JS makes this a better application.

    #337655 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    303 pts
    @timk

    I had that written up somewhere… Let me see if I can find it.

    #337741 Score: 0
    Profile photo of Mkia
    Mkia
    Member
    beginner
    intermediate
    friend finder
    contributor
    wise owl
    advanced
    curious george
    3 pts
    @Mkia

    Yess!! Thank you guys!!

    That’s exactly what I needed….and it works!

    #337826 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    303 pts
    @timk
    #337957 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    199 pts
    @Klaatu

    Very nice, Tim. Thank you for sharing this. It’s obvious you put a lot of work into it.

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.