Documentation
¶
Overview ¶
Package dialog ships the modal Dialog view: a Window dressed in the gray dialog palette, with helpers for laying out a row of buttons along the bottom edge.
A Dialog is just a Window with FlagClose|FlagMove (no zoom, no grow) and the frame swapped to the dialog palette slots. Insert child widgets the same way you would with a Window. Phase 3 wires Enter and Esc shortcuts; the modal sub-loop arrives with Application.ExecView.
Index ¶
- Constants
- type Dialog
- func (d *Dialog) CancelButton() *widget.Button
- func (d *Dialog) DefaultButton() *widget.Button
- func (d *Dialog) EndModal(cmd event.CommandID)
- func (d *Dialog) HandleEvent(e *event.Event)
- func (d *Dialog) PlaceButtons(buttons ...*widget.Button)
- func (d *Dialog) Reset()
- func (d *Dialog) Result() event.CommandID
- func (d *Dialog) SetCancelButton(b *widget.Button)
- func (d *Dialog) SetDefaultButton(b *widget.Button)
- type Flags
Constants ¶
const ( MbOK = KindInformation | BtnOK MbOKCancel = KindConfirmation | BtnOK | BtnCancel MbYesNo = KindConfirmation | BtnYes | BtnNo MbYesNoCancel = KindConfirmation | BtnYes | BtnNo | BtnCancel )
Stock button combinations.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dialog ¶
Dialog is a modal Window themed for forms and prompts. Embed *window.Window so all the framing, drag, and event-dispatch logic is inherited; Dialog only customizes palette slots and adds a button placement helper.
func MessageBox ¶
MessageBox returns a Dialog that displays text with the title and buttons selected by flags. The dialog is not yet inserted anywhere; pass it to Application.ExecView (or similar) to show it modally.
Lines in text are split on '\n'. Long lines are clipped at mbMaxW; the helper does not word-wrap. The first present button in (OK, Yes, No, Cancel) becomes the default; Cancel (or No when no Cancel exists) becomes the cancel button.
func New ¶
New returns a Dialog sized to bounds. The frame uses dialog slots (15 inactive, 16 active), the body fills with dialog text color, and FlagClose|FlagMove are enabled so the user can drag and dismiss.
func (*Dialog) CancelButton ¶
CancelButton returns the button registered via SetCancelButton, or nil.
func (*Dialog) DefaultButton ¶
DefaultButton returns the button registered via SetDefaultButton, or nil.
func (*Dialog) EndModal ¶
EndModal records cmd as the dialog's close result. Hosts call this when they want to dismiss the dialog programmatically; the modal sub-loop exits on the next iteration.
func (*Dialog) HandleEvent ¶
HandleEvent intercepts dialog-level shortcuts before falling back to the Window dispatch. Enter fires the registered default button; Esc fires the registered cancel button. A disabled button is skipped so the rest of the dispatch chain still gets the keystroke. Command events that close the dialog (CmdOk, CmdCancel, CmdYes, CmdNo, CmdClose) are also captured here and stashed as the close result.
func (*Dialog) PlaceButtons ¶
PlaceButtons inserts the given buttons in a centered row along the bottom of the client rectangle. Buttons keep the size set by the caller; PlaceButtons only repositions them. Useful for the common OK/Cancel cluster a host doesn't want to lay out by hand.
func (*Dialog) Reset ¶
func (d *Dialog) Reset()
Reset clears the close result so the same Dialog instance can be shown a second time.
func (*Dialog) Result ¶
Result returns the command that closed the dialog, or 0 if the dialog has not been closed yet. ExecView reads this to decide when the modal sub-loop should exit.
func (*Dialog) SetCancelButton ¶
SetCancelButton remembers b as the dialog's cancel action so pressing Esc anywhere in the dialog fires it. Pass nil to clear.
func (*Dialog) SetDefaultButton ¶
SetDefaultButton remembers b as the dialog's default action so pressing Enter anywhere in the dialog fires it. Pass nil to clear.