class BBS::WindowSpec

Declarative window definition used inside Application.define:

window :compose, type: :form do |w|
  w.title { |ctx| " Post to #{ctx[:board].title} " }
  w.width 70
  w.field :body, type: :textarea, max_length: 1000
  w.on_submit do |values, form, ctx|
    case ctx[:boards].post(ctx[:board].id, ctx[:username], values[:body])
    when :empty then form.error('Message cannot be empty.'); :keep
    else :close
    end
  end
end

w.maximizable true gives the window the zoom gadget (F5, Alt-Enter): it fills the screen and back. Worth it for windows with a lot to read.

Open with app.open_window(:compose, board: some_board). Block callbacks receive a ctx hash combining the app’s services, app.context, and any extras passed to open_window.

The type picks the window class: :info (BBS::Windows::Info), :form (BBS::Windows::Form), :master_detail (BBS::Windows::MasterDetail) or :stream (BBS::Windows::Stream). Each name in SCALAR_ATTRS and BLOCK_ATTRS is a setter method that takes a value or a block; a block is called with ctx (and the callback’s own arguments first, for the callbacks) when the window opens.