Task

Create a window that has:

   a label that says   "There have been no clicks yet" 
   a button that says   "click me"


Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.




MODULE Click EXPORTS Main;
 
IMPORT Fmt, TextVBT, ButtonVBT, VBT, Axis, HVSplit, TrestleComm, Trestle;
 
VAR label := TextVBT.New("There have been no clicks yet.");
    button := ButtonVBT.New(TextVBT.New("Click me!"), Clicked);
    main := HVSplit.Cons(Axis.T.Ver, label, button, adjustable := FALSE);
    count := 0;
 
PROCEDURE Clicked(<*UNUSED*>button: ButtonVBT.T; <*UNUSED*>READONLY cd: VBT.MouseRec) =
  BEGIN
    INC(count);
    TextVBT.Put(label, "Button pressed: " & Fmt.Int(count));
  END Clicked;
 
<*FATAL TrestleComm.Failure*>
BEGIN
  Trestle.Install(main);
  Trestle.AwaitDelete(main);
END Click.