-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathbutton.lisp
33 lines (28 loc) · 999 Bytes
/
button.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
(in-package #:jupyter/widgets)
(defwidget button (styled-widget button-style-slot disabled-slot icon-slot
tooltip-slot)
((description
:initarg :description
:accessor widget-description
:documentation "Button label."
:trait :string)
(on-click
:initarg :on-click
:initform nil
:accessor widget-on-click))
(:default-initargs
:%model-name "ButtonModel"
:%view-name "ButtonView"
:style (make-instance 'button-style))
(:documentation "Button widget.
This widget has an `on-button-click` method that allows you to listen for the
user clicking on the button. The click event itself is stateless."))
(defun on-button-click (widget handler)
(push handler (widget-on-click widget)))
(defmethod on-custom-message ((w button) content buffers)
(declare (ignore buffers))
(if (equal (gethash "event" content) "click")
(dolist (handler (widget-on-click w))
()
(funcall handler w))
(call-next-method)))