On this page:
expandable-snip%
new
get-open-editor
get-closed-editor

6 Expandable Snip

 (require mrlib/expandable-snip) package: gui-lib

class

expandable-snip% : class?

  superclass: editor-snip%

An expandable snip allows the user to toggle between two views—“open” and “closed”—implemented by two text editors. Typically the closed view is a concise summary and the open view contains more detailed information. The syntax browser snip is an example of an expandable snip.

constructor

(new expandable-snip% 
    [[layout layout] 
    [closed-editor closed-editor] 
    [open-editor open-editor] 
    [callback callback]] 
    ...superclass-args...) 
  (is-a?/c expandable-snip%)
  layout : (or/c 'append 'replace) = 'append
  closed-editor : (is-a?/c text%) = (new text%)
  open-editor : (is-a?/c text%) = (new text%)
  callback : (-> boolean? any) = void
The callback is called when the snip state is toggled. It is called with a boolean that indicates whether the new state is open.

In closed mode, the toggle arrow and closed-editor are displayed adjacent on a single line. In open mode, the layout is controlled by the layout argument as follows:
  • 'append The first line is unchanged (that is, it contains both toggle arrow and closed-editor), and open-editor is displayed on the second line.

  • 'replace The toggle arrow and the open-editor are displayed on a single line. The closed-editor is not displayed.

method

(send an-expandable-snip get-open-editor)  (is-a?/c text%)

Get the editor for the open mode.

method

(send an-expandable-snip get-closed-editor)  (is-a?/c text%)

Gets the editor for the closed mode.