Permalink
Browse files

Example of using hyperlink events in html editor pane.

  • Loading branch information...
1 parent 2f36c9d commit d52216f4c5d4b4738a8c9710436639d607abd8e0 @daveray committed Jan 24, 2012
Showing with 53 additions and 0 deletions.
  1. +52 −0 test/seesaw/test/examples/editor_pane_hyperlink.clj
  2. +1 −0 test/seesaw/test/examples/launcher.clj
@@ -0,0 +1,52 @@
+; Copyright (c) Dave Ray, 2012. All rights reserved.
+
+; The use and distribution terms for this software are covered by the
+; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
+; which can be found in the file epl-v10.html at the root of this
+; distribution.
+; By using this software in any fashion, you are agreeing to be bound by
+; the terms of this license.
+; You must not remove this notice, or any other, from this software.
+
+(ns seesaw.test.examples.editor-pane-hyperlink
+ (:use seesaw.core
+ seesaw.test.examples.example)
+ (:import javax.swing.event.HyperlinkEvent
+ javax.swing.event.HyperlinkEvent$EventType))
+
+(defn make-editor-pane
+ []
+ (editor-pane
+ :id :editor
+ :content-type "text/html"
+ :editable? false
+ :text "<html>
+ You can click a link and get an event:
+ <ul>
+ <li><a href='apple'>Apple</a></li>
+ <li><a href='banana'>Banana</a></li>
+ <li><a href='chocolate'>Chocolate</a></li>
+ <li><a href='durian'>Durian</a></li>
+ <li><a href='egg'>Egg</a></li>
+ </ul>
+ </html>"))
+
+(defn add-behaviors
+ [root]
+ (let [editor (select root [:#editor])]
+ (listen editor :hyperlink
+ (fn [e]
+ (when (= HyperlinkEvent$EventType/ACTIVATED (.getEventType e))
+ (alert e (str "Clicked: " (.getDescription e)))))))
+ root)
+
+(defexample []
+ (->
+ (frame
+ :title "Editor Pane Hyperlinks"
+ :content (make-editor-pane))
+ add-behaviors))
+
+;(run :dispose)
+
+
@@ -28,6 +28,7 @@
'dialog
'dnd
'dynamic-layout
+ 'editor-pane-hyperlink
'explorer
'form
'forms

0 comments on commit d52216f

Please sign in to comment.