VASmalltalk – KeyPressed events under Seaside …

I had a simple use case under Seaside. I wanted to send the keyboard codes pressed in a browser to my Seaside Smalltalk server ….

I searched around and I found this question also on the Seaside list, but all answers I read there (from professional Seasiders) were that short, that I did not understand them at all – and this is a very general problem with Seaside: it is very often assumed, that you must be familiar with all that Javascript stuff and all those libraries and how they work and then you might use Seaside to wrap those libraries. I have to admit, that it would be very good to learn jQuery and all those others Javascript libraries just to write Smalltalk code to control those libraries – but perhaps it would be better just to switch to those Javascript libraries and leave Smalltalk alone ???

Perhaps it would be better to write all that Seaside documentation from a primary smalltalk perspective and in a secondary view from a Javascript perspective – then you might read both different views to get a different introduction

The problem with those keycodes ? Well with lots of tries and errors I found Smalltalk code giving me some information in Smalltalk:

renderContentOn: html
  html 
    script: (html jQuery this 
               onKeyPress: (((html jQuery ajax 
                  callback: [ :keyInfo | keyInfo inspect ] 
                  value: (Array 
                           with: (JSStream on: 'arguments[0].which')
                           with: (JSStream on: 'arguments[0].keyCode'))   )
                  ) asFunction: (Array with: 'e'))
            ).	
This entry was posted in Smalltalk. Bookmark the permalink.

4 Responses to VASmalltalk – KeyPressed events under Seaside …

  1. Philippe Marschall says:

    You’re basically right. You have to be familiar to with the JavaScript libraries. But that’s intentional. To produce HTML in Seaside you have to be familiar with HTML You have to know what you want to produce because the canvas is just “a DSL for generating HTML” with a more or less one to one mapping. This gives you very much control but you have to know what you’re doing. It’s the same with JavaScript. Anything non-trivial you probably want to write in JavaScript itself.

    So my recommendation to you is to learn JavaScript and jQuery. They are both easy to learn.

  2. Joachim says:

    Hi Marten,

    you’re pointing to a weak spot in available Seaside information: Javascript Integration is not really well documented. It’s sometimes a bit hard to understand the concept of rendering JavaScript code in Smalltalk. I tend to write more and more JavaScript code and put it into file libraries, mostly in the form of jQuery plugins. Thus I reduce the complexity of the Smalltalk side.

    Maybe you could explain a bit more in depth what your code sample does, or add the resulting JavaScript code to the posting to make things more obvious….

  3. schrievkrom says:

    My posting is an answer to the thread available at: http://lists.squeakfoundation.org/pipermail/seaside/2010-July/023842.html.

    It sends Smalltalk information, when the user is pressed a keyboard in its browser – actually it sends some (browser dependent) key code. Use case ? Consider a GUI, where you have only a remote control to change the WWW pages.

  4. Bob Nemec says:

    Lately I find myself finding web development solutions in javascript (like iPad support) and then working backwards to see how Seaside can generate the code. It’s impressive to see some of the clever Smalltalk code used to generate tricky javascript. JQAutocomplete>>search:labels:callback: is a good example.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s