Page 1 of 1

How to execute method when CR entered in text_area

PostPosted: Sun Apr 27, 2014 4:44 pm
by Westy
Is there a way within Servoy webclient to execute a method when a user enters a carriage return within a text_area field?

Dean

Re: How to execute method when CR entered in text_area

PostPosted: Sun Apr 27, 2014 4:56 pm
by david
Web client only, you can put a client-side key listener on the field and trigger a server-side method on CR using web utils.

Re: How to execute method when CR entered in text_area

PostPosted: Sun Apr 27, 2014 5:12 pm
by Westy
"client-side key listener"

I am not familiar with this. Does it require the client to install software? Is there any documentation that I can read on this?

Dean

Re: How to execute method when CR entered in text_area

PostPosted: Sun Apr 27, 2014 6:13 pm
by david
Webclient utils plugin is over on ServoyForge. It has a bunch of functionality that allows you to run client-side javascript in webclient (as opposed to Servoy methods which run server-side). Use that to add your own event listener to a web area and run some servoy code when the listener is trigger (which is on every key press then filtered to just the CR/13). Don't have Servoy open but here is some pseudo code:

Code: Select all
// 1. webclient utils: grab ID of text area

// 2. webclient utils: register a servoy callback method

// 3. web client utils: add your own listener to a specific text area
$("#TextAreaID").keypress(function(e) {
    if(e.which == 13) { // 13 == CR
        alert('You pressed enter!'); // for debugging
      // call registered servoy callback method here
    }
});

Re: How to execute method when CR entered in text_area

PostPosted: Mon Apr 28, 2014 12:50 am
by Westy
Thank you for this info.

Dean