[Prev][Next][Index][Thread]

Support for HTML input type button.




For the convenience of writing JavaScript that can respond to buttons on
the page, I found it useful to add a new type of form "accept input"
object, namely a "button".  This corresponds to the button object and
can be used with Javascript events to create useful interface elemen.
This requires adding the following code to CL-HTTP:

==== Begin included code ===============================================
;;;-*- Mode: Lisp; Package: NETSCAPE2.0 -*-

(in-package "NETSCAPE2.0")

(html2::define-input-type
  button
  :type-arg "BUTTON"
  :lisp-type 'null)

(defmethod accept-input ((button button) query-name &rest args &key (stream *output-stream*) &allow-other-keys)
  (destructuring-bind (&key display-string &allow-other-keys) args
    (%issue-command ("INPUT" stream)
      (write-standard-input-type-args (stream query-name button args :bind-default nil)
	(%write-command-key-arg stream "VALUE" (or display-string "Push Me")) ))))

==== End included code ===============================================

It can be used inside a form like this:

  (let ((script (ns2.0:intern-script :my-script :java-script)))
     (html::with-event-handlers
        (button
	  (:java-script
	   :mouse-click (ns2.0:event-caller script ...)))
	(html2:accept-input 'ns2.0::button "choose"
   	   :display-string "Choose Some"
           :events button :stream stream)))


-Tom.
________________________________________________________________________
Thomas A. Russ,  Senior Research Scientist                   tar@isi.edu    
USC/Information Sciences Institute              WWW:  http://www.isi.edu
4676 Admiralty Way, Marina del Rey, CA 90292          (310) 822-1511x775


Follow-Ups: