[comp.sys.mac.hypercard] Can buttons be created on the fly?

a347@mindlink.UUCP (John Miller) (01/11/91)

> I'd like to create buttons dynamically within a script, but I
> haven't found a way to do this.

A new button can be created using the command
  domenu "New Button"

The trick is gaining access to this button so that you can set the
name and location.  The button is added to the "end of the list."

        -- Create the button
        domenu "New Button"
        -- Figure out the button number
        put the number of buttons into btnNumb
        -- Make it look right
        set the name of button btnNumb to "Bob"
        set the rect of button btnNumb to 10,40,80,60
        set the style of button btnNumb to "shadow"
        -- Be sure to go back to browse tool after creating
        -- all the buttons
        choose browse tool

You might want to use "lock screen" and "unlock screen" around these
statements so that the user doesn't see the button until the
script has finished building it.

----------------------------------------------------------------------
John Miller                         (604) 433-1795
Symplex Systems                     AppleLink (rarely)  CDA0461
Burnaby, British Columbia           Fax: (604) 430-8516
Canada                              usenet:  john_miller@mindlink.uucp
----------------------------------------------------------------------

jamii@oxygen.uucp (Jamii K. Corley) (01/12/91)

 I'm new to HyperCard programming and have an application that I think should
be fairly easy to create, but I can't seem to find a way of doing it. I have
a file that contains some subject headers and articles. I'd like to read it
with Hyper Card and create a page of buttons one for each subject. Since I
don't know what these subjects will be a head of time, I'd like to create
buttons dynamically within a script, but I haven't found a way to do this.
 Any suggestions are welcomed.
       Thanks,
                 Jamii Corley

  -----------jamii@edsr.eds.com   or ....uunet!edsr!jamii------------------
"Everyday, once a day, give yourself a present. Don't plan it, don't wait for it
just let it happen. It could be a new shirt from the men's store, a cat nap in
your office chair, or two cups of hot black coffee." - Agent Dale Cooper, TP

kofoid@bioscience.utah.edu (Eric Kofoid) (01/13/91)

In article <4413@mindlink.UUCP> a347@mindlink.UUCP (John Miller) writes:
> > I'd like to create buttons dynamically within a script, but I
> > haven't found a way to do this.
> 
> A new button can be created using the command
>   domenu "New Button"
> 
> The trick is gaining access to this button so that you can set the
> name and location.  The button is added to the "end of the list."
> 
>         -- Create the button
>         domenu "New Button"
>         -- Figure out the button number
>         put the number of buttons into btnNumb
>         -- Make it look right
>         set the name of button btnNumb to "Bob"
>         set the rect of button btnNumb to 10,40,80,60
>         set the style of button btnNumb to "shadow"
>         -- Be sure to go back to browse tool after creating
>         -- all the buttons
>         choose browse tool
<etc.>

An even simpler solution:

         domenu "New Button"
         set name of last btn to "Bob"
         set rect of last btn to 10,40,80,60
         set style of last btn to "shadow"
         choose browse tool

Cheers,

Eric.

 __________________________________________________________________
|       Eric Kofoid; Dept. Biology, U. of Utah; SLC, UT 84112      |
|                          (801) 581-3592                          |
|                     kofoid@bioscience.utah.edu                   |
|                                                                  |
| -- The University of Utah is blameless for anything I've said -- |
|__________________________________________________________________|