On this page:
notify-box%
get
set
listen
remove-listener
remove-all-listeners
notify-box/ pref
notify-box/ pref/ readonly
menu-option/ notify-box
check-box/ notify-box
choice/ notify-box
menu-group/ notify-box
Version: 4.2.3

18.1 Notify-boxes

 (require unstable/gui/notify)

notify-box% : class?

  superclass: object%

A notify-box contains a mutable cell. The notify-box notifies its listeners when the contents of the cell is changed.

(new notify-box% [value value])  (is-a?/c notify-box%)
  value : any/c
Creates a notify-box with the initial value value.
(send a-notify-box get)  any/c
Gets the value currently stored in the notify-box.
(send a-notify-box set v)  void?
  v : any/c
Updates the value stored in the notify-box and notifies the listeners.
(send a-notify-box listen listener)  void?
  listener : (-> any/c any)
Adds a callback to be invoked on the new value when the notify-box’s contents change.
(send a-notify-box remove-listener listener)  void?
  listener : (-> any/c any)
Removes a previously-added callback.
(send a-notify-box remove-all-listeners)  void?
Removes all previously registered callbacks.

(notify-box/pref proc)  (is-a?/c notify-box%)
  proc : (case-> (-> any/c) (-> any/c void?))
Creates a notify-box with an initial value of (proc) that invokes proc on the new value when the notify-box is updated.

Useful for making a notify-box tied to a preference or parameter.

(notify-box/pref/readonly proc)  (is-a?/c notify-box%)
  proc : (-> any/c)
Creates a notify-box with an initial value of (proc).

Useful for making a notify-box that takes its initial value from a preference or parameter but does not update the preference or parameter.

(menu-option/notify-box parent 
  label 
  notify-box) 
  (is-a?/c checkable-menu-item%)
  parent : (or/c (is-a?/c menu%) (is-a?/c popup-menu%))
  label : label-string?
  notify-box : (is-a?/c notify-box%)
Creates a checkable-menu-item% tied to notify-box. The menu item is checked whenever (send notify-box get) is true. Clicking the menu item toggles the value of notify-box and invokes its listeners.

(check-box/notify-box parent    
  label    
  notify-box)  (is-a?/c check-box%)
  parent : 
(or/c (is-a?/c frame%) (is-a?/c dialog%)
      (is-a?/c panel%) (is-a?/c pane%))
  label : label-string?
  notify-box : (is-a?/c notify-box%)
Creates a check-box% tied to notify-box. The check-box is checked whenever (send notify-box get) is true. Clicking the check box toggles the value of notify-box and invokes its listeners.

(choice/notify-box parent    
  label    
  choices    
  notify-box)  (is-a?/c choice%)
  parent : 
(or/c (is-a?/c frame%) (is-a?/c dialog%)
      (is-a?/c panel%) (is-a?/c pane%))
  label : label-string?
  choices : (listof label-string?)
  notify-box : (is-a?/c notify-box%)
Creates a choice% tied to notify-box. The choice control has the value (send notify-box get) selected, and selecting a different choice updates notify-box and invokes its listeners.

If the value of notify-box is not in choices, either initially or upon an update, an error is raised.

(menu-group/notify-box parent 
  labels 
  notify-box) 
  (listof (is-a?/c checkable-menu-item%))
  parent : (or/c (is-a?/c menu%) (is-a?/c popup-menu%))
  labels : (listof label-string?)
  notify-box : (is-a?/c notify-box%)
Returns a list of checkable-menu-item% controls tied to notify-box. A menu item is checked when its label is (send notify-box get). Clicking a menu item updates notify-box to its label and invokes notify-box’s listeners.