On Wed, Feb 24, 2010 at 3:38 PM, Rick R <rick.richard...@gmail.com> wrote:

> That works beautifully, thanks.
>
> With regards to using custom javascript functions,  I have a function
> processKeyPress. It's role is to filter key presses, only send events
> to the server upon certain key presses.
>
> I guess the easiest way to handle this would be to pass the function
> created by:
>  {jsonCall("pressed", JsRaw("event.which")).toJsCmd}
>

How about:

onkeypress={"processKeyPress(function(a) {"+jsonCall("pressed",
JsRaw("a")).toJsCmd+"})"}

This will pass a function to the processKeyPress method.  If you want to
send the message, you call the function with the value to send to the
server.


>
> into processKeyPress so that it can invoke it if the event.which is
> the correct type.
>
> Unfortunately, I can't come up with a way to describe this in inline XML.
>
> <input type="textarea" onkeypress="processKeyPress(event.which,
> {jsonCall("pressed", JsRaw("event.which")).toJsCmd})"/>
>
> leaving out the " causes a parse error.. adding the " cause it to be
> evaulated as a string.
>
> Any ideas?
>
>
>
> On Wed, Feb 24, 2010 at 2:57 PM, David Pollak
> <feeder.of.the.be...@gmail.com> wrote:
> > Rick,
> >
> > Here's a simple example:
> >
> > import net.liftweb._
> > import util._
> > import http._
> > import js._
> > import JsCmds._
> > import JE._
> > import scala.xml.NodeSeq
> >
> > class Evently extends CometActor {
> >
> >   // handle an incoming JSON event
> >   override def handleJson(in: Any): JsCmd = in match {
> >     case JsonCmd("pressed", _, key, _) => SetHtml("info", <b>You pressed
> > {key}</b>)
> >     case _ => Noop
> >   }
> >
> >   def render =
> >   <div>
> >   <span id="info"/> <!-- A place to put stuff -->
> >   {
> >     Script(jsonInCode) // include the JSON callback
> >   }
> >    <input type="text" onkeypress={jsonCall("pressed",
> > JsRaw("event.which")).toJsCmd}/>
> >   </div>
> > }
> >
> > So, the handleJson message gets called on the server whenever a key is
> > pressed on the client (this example works in non-IE browsers, but that's
> > just 'cause I'm using event.which rather than event.keyCode).
> >
> > Hope this helps.
> >
> > Thanks,
> >
> > David
> >
> >
> > On Wed, Feb 24, 2010 at 8:23 AM, Rick R <rick.richard...@gmail.com>
> wrote:
> >>
> >> I have a textarea in which I process onKeyUp and onKeyDown commands.
> >> The handlers for such things are custom javascript.
> >> I would like to invoke functions in a Comet LiftActor /
> >> ListenerManager via these custom javascript functions. Is there
> >> documentation on the recommended way to do so?
> >>
> >> It looks like I will have to define the functions within a render call
> >> and use the SHtml.ajaxCall function, since the destination url is
> >> randomized.  I am just wondering what would be the idiomatic way to do
> >> this.
> >>
> >> This is for a chat style app which processes/distributes data by the
> >> keystroke rather than by a  line/post command.
> >>
> >>
> >> I'm open to any ideas / alternate suggestions.
> >>
> >> Thanks,
> >> Rick
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Lift" group.
> >> To post to this group, send email to lift...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com>
> .
> >> For more options, visit this group at
> >> http://groups.google.com/group/liftweb?hl=en.
> >>
> >
> >
> >
> > --
> > Lift, the simply functional web framework http://liftweb.net
> > Beginning Scala http://www.apress.com/book/view/1430219890
> > Follow me: http://twitter.com/dpp
> > Surf the harmonics
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lift...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com>
> .
> > For more options, visit this group at
> > http://groups.google.com/group/liftweb?hl=en.
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.

Reply via email to