packages feed

vty-ui-1.0: doc/ch4/Button.tex

\section{Buttons}

The \fw{Button} module provides a button-like widget, \fw{Button},
which can accept the focus and produce a ``pressed'' event when the
user presses \fw{Enter}.

Buttons can be created with the \fw{newButton} function.  The function
takes the text to be displayed on the button.

\begin{haskellcode}
 b <- newButton "OK"
\end{haskellcode}

To handle ``button-press'' events, use the \fw{onButtonPressed}
function.  Event handlers are passed a reference to the \fw{Button}
itself.

\begin{haskellcode}
 b `onButtonPressed` \this ->
   ...
\end{haskellcode}

To change the text of the button, use the \fw{setButtonText} function.
To ``press'' the button programmatically, call \fw{pressButton}.

When you are ready to add the \fw{Button} to your interface, call its
\fw{buttonWidget} function:

\begin{haskellcode}
 box <- (plainText "Are you sure?") <--> (return (buttonWidget b))
\end{haskellcode}

\subsubsection{Growth Policy}

\fw{Buttons} never grow in either dimension.