How to execute method when CR entered in text_area

Questions, tips and tricks and techniques for scripting in Servoy

How to execute method when CR entered in text_area

Postby Westy » Sun Apr 27, 2014 4:44 pm

Is there a way within Servoy webclient to execute a method when a user enters a carriage return within a text_area field?

Dean
Westy
 
Posts: 845
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Re: How to execute method when CR entered in text_area

Postby david » Sun Apr 27, 2014 4:56 pm

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.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: How to execute method when CR entered in text_area

Postby Westy » Sun Apr 27, 2014 5:12 pm

"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
Westy
 
Posts: 845
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA

Re: How to execute method when CR entered in text_area

Postby david » Sun Apr 27, 2014 6:13 pm

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
    }
});
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: How to execute method when CR entered in text_area

Postby Westy » Mon Apr 28, 2014 12:50 am

Thank you for this info.

Dean
Westy
 
Posts: 845
Joined: Fri Feb 13, 2004 5:27 am
Location: Lynnfield, Massachusetts USA


Return to Methods

Who is online

Users browsing this forum: No registered users and 3 guests