Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed :content for menu-bar, tool-bar

  • Loading branch information...
commit 2c7140281f38b2d7686b08246df15117d8a41a1f 1 parent ba2eae5
@odyssomay authored
Showing with 18 additions and 5 deletions.
  1. +12 −4 src/Hafni/swing/menu.clj
  2. +6 −1 src/Hafni/test/swing/menu.clj
View
16 src/Hafni/swing/menu.clj
@@ -26,11 +26,14 @@ Fields:
(defn menu-bar
"Create a JMenuBar
Fields:
- :content - content of menu bar | [Component]"
+ :content - content of menu bar (not changeable) | [Component]"
[& options]
(let [m (JMenuBar.)
last_items (atom [])
- arrs {:content (partial change-menu-content m last_items)}]
+ arrs {:content
+ (fn [coll]
+ (dorun
+ (map #(.add m (component %)) coll)))}]
(init-comp m arrs {} (parse-options options))))
(defn popup-menu
@@ -48,13 +51,18 @@ close when an item is choosed."
(defn tool-bar
"Create a JToolBar
Fields:
- :content - content of toolbar | [Component]
+ :content - content of toolbar (not changeable) | [Component]
:floatable - if the toolbar is detachable | Bool
:rollover - if true, shows a visual indicator under the cursor | Bool"
[& options]
(let [t (JToolBar.)
last_items (atom [])
- arrs {:content (partial change-menu-content t last_items)
+ arrs {:content
+ (fn [coll]
+ (dorun
+ (map #(if (= % [])
+ (.addSeparator t)
+ (.add t (component %))) coll)))
:floatable #(.setFloatable t %)
:rollover #(.setRollover t %)}]
(init-comp t arrs {} (parse-options options))))
View
7 src/Hafni/test/swing/menu.clj
@@ -2,7 +2,7 @@
(:use (Hafni arrow utils)
(Hafni.swing action component layout menu view)))
-(defn menu-toolbar-test []
+(defn menu-bar-test []
(let [m (menu "menu 1" :content [(menu-item :text "item 1") []
(menu-item :text "item 2")])]
(frame :menu_bar (menu-bar :content [m])
@@ -17,3 +17,8 @@
(input-arr m :content)))])
:size 300 300 :dont_exit_on_close)))
+(defn toolbar-test []
+ (frame :content (border-layout :north (tool-bar :content [(button :text "1")
+ (button :text "2")
+ (button :text "3")]))
+ :size 300 300 :dont_exit_on_close))
Please sign in to comment.
Something went wrong with that request. Please try again.