Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Set the default button for the login and create user windows.

  • Loading branch information...
commit 0e009435e2db3705844616431e936b14f67e5275 1 parent 000ed27
@macourtney authored
View
6 src/darkexchange/controller/actions/utils.clj
@@ -32,4 +32,8 @@
(defn remove-all-action-listeners [button]
(doseq [action-listener (.getActionListeners button)]
- (.removeActionListener button action-listener)))
+ (.removeActionListener button action-listener)))
+
+(defn set-default-button [parent-frame button]
+ (.setDefaultButton (.getRootPane parent-frame) button)
+ parent-frame)
View
8 src/darkexchange/controller/login/create_user.clj
@@ -63,8 +63,14 @@
(defn attach-register-action [create-user-frame]
(actions-utils/attach-listener create-user-frame "#register-button" create-user-action))
+(defn find-register-button [create-user-frame]
+ (seesaw-core/select create-user-frame ["#register-button"]))
+
+(defn attach-default-button [create-user-frame]
+ (actions-utils/set-default-button create-user-frame (find-register-button create-user-frame)))
+
(defn attach [create-user-frame]
- (attach-register-action (attach-cancel-action create-user-frame)))
+ (attach-default-button (attach-register-action (attach-cancel-action create-user-frame))))
(defn show [login-frame]
(controller-utils/show (attach (create-user-view/create login-frame))))
View
12 src/darkexchange/controller/login/login.clj
@@ -73,8 +73,18 @@
(defn attach-login-action [login-frame]
(actions-utils/attach-listener login-frame "#login-button" login-action))
+(defn find-login-button [login-frame]
+ (seesaw-core/select login-frame ["#login-button"]))
+
+(defn attach-default-button [login-frame]
+ (actions-utils/set-default-button login-frame (find-login-button login-frame)))
+
(defn attach [login-frame]
- (attach-cancel-action (attach-login-action (attach-new-user-action (attach-user-add-listener login-frame)))))
+ (attach-default-button
+ (attach-cancel-action
+ (attach-login-action
+ (attach-new-user-action
+ (attach-user-add-listener login-frame))))))
(defn show []
(controller-utils/show (attach (load-data (login-view/create)))))
View
4 src/darkexchange/controller/utils.clj
@@ -9,7 +9,9 @@
(seesaw-core/select parent-component [id]))
(defn show [frame]
- (seesaw-core/show! frame))
+ (if frame
+ (seesaw-core/show! frame)
+ (logging/warn "Show was given a nil frame.")))
(defn create-item-listener [item-listener-fn]
(reify ItemListener
Please sign in to comment.
Something went wrong with that request. Please try again.