Glimmr Form Fields

version 1/101201 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next

  • Example: * Minimalist Exercise - This example illustrates the basics of usage, with a single form field in which the player is invited to type a handful of characters. The text typed is echoed back in the main window. If the player types a number (positive or negative), the input will be interpreted as a number and that too will be echoed.

    You may prefer to do a release build and run this in a standalone interpreter for better performance. If you choose not to release to a standalone file, you may need to type slowly into the field.

        "Minimalist Exercise"

        Include Glimmr Form Fields by Erik Temple.
        Include Glimmr Bitmap Font by Erik Temple.
        Include Glimmr Simple Graphics Window by Erik Temple.
        [Use input loop debugging.]
        The graphics-window is a graphics g-window spawned by the main-window. The position is g-placeabove. The back-colour is g-steelblue. The graphics-window is g-graphlinked.
        The graphics-canvas is a g-canvas. The canvas-width is 51. The canvas-height is 40.
        The associated canvas of the graphics-window is the graphics-canvas. The associated canvas of a g-element is usually the graphics-canvas.
        When play begins:
            open up the graphics-window.
        An input field is a kind of stroked rectangle primitive. The associated canvas of an input field is the graphics-canvas. The maximum length is 5. An input field is numerical.
        My form field is an input field. The origin is {5, 10}. The endpoint is {46, 30}. The background tint of an input field is usually g-navy. The tint of an input field is g-white.
        My text is a bitmap-rendered string. The origin is {8, 15}. The tint is g-indigo. The input-stream of my form field is my text.
        Test is a room. "You may type up to 5 characters in the field above. Go ahead, try it. Press Enter when you've finished."
        Last carry out accepting field input:
            say "You typed '[text-string of my text]' (interpreted as the number [associated value of my form field]) in the field[first time]. Click in the field again to change or add to what you typed; you can delete text using the backspace key, or use the left and right arrow keys to move the cursor[only]."