[comp.sys.mac.hypercard] Fast way to create a button?

tgl@zog.cs.cmu.edu (Tom Lane) (09/21/88)

I have a stack in which I would like to automatically create a card button
on each new card (and no, a background button is not a better solution;
details on request).  The best way I've found to do this is to include a
doMenu "New Button" in my newCard handler, thus:

on newCard
  lock screen
  doMenu "New Button"
  choose browse tool      -- deselect the button tool
  set the style of card button 1 to radioButton
  -- etc for about four other properties
  unlock screen
end newCard

Unfortunately, this is ridiculously slow.  While a vanilla "new card"
operation takes about 0.6 second on my Mac Plus, with this handler
installed it takes about 2.85 seconds to make a new card.  Setting the
button properties doesn't take much time; it's almost all going into the
"New Button" operation.  (although "choose browse tool" seems to take a
rather long time for an operation that doesn't really do anything...)

An only slightly less annoying aspect is that the cursor flickers
during this handler, even though the screen is locked.  (It doesn't
seem to change shape, but it does flicker.)  This could be a bug in
HyperCard -- I'm using version 1.2.

Anybody know a faster way to create a button?

Extra credit question: Why does creating a button take twice as long as
creating a card?

-- 
				tom lane
Internet: tgl@zog.cs.cmu.edu
UUCP: <your favorite internet/arpanet gateway>!zog.cs.cmu.edu!tgl
BITNET: tgl%zog.cs.cmu.edu@cmuccvma

stone@hydra.unm.edu.unm.edu (Andrew Stone CS.DEPT) (09/22/88)

In article <3060@pt.cs.cmu.edu> tgl@zog.cs.cmu.edu (Tom Lane) writes:
>I have a stack in which I would like to automatically create a card button
>on each new card (and no, a background button is not a better solution;
>details on request).  The best way I've found to do this is to include a
>doMenu "New Button" in my newCard handler, thus:
>
>on newCard
	[ his way ]

I developed a  stack, "le Artiste" which required that the "tool"
bar button be a card button, else the new art would obscure it.

So to create a new card with this special button in the card layer, 
I trap the domenu "new card" and call `myNewCard':

on myNewCard
  choose button tool
  click at loc of btn theCardButton
  domenu "Copy Button"
  send "Domenu new card" to hypercard -- the crux of the biscuit
	-- how to avoid infinite loop with on domenu which
  domenu "Paste Button"
  choose browse tool
end myNewCard

>An only slightly less annoying aspect is that the cursor flickers
>during this handler, even though the screen is locked.  (It doesn't
>seem to change shape, but it does flicker.)  This could be a bug in
>HyperCard -- I'm using version 1.2.

add " set cursor to none" and see what happens


>				tom lane
>Internet: tgl@zog.cs.cmu.edu

	--andrew


||<<++>>||<<-->>||<<==>>||<<++>>||<<??>>||<<++>>||<<-->>||<<==>>||<<++>>||
||                                                                      ||
||	   Andrew Stone	    stone@hydra.unm.edu	    (505) 345-4800      ||
||                                                                      ||
||<<++>>||<<-->>||<<==>>||<<++>>||<<??>>||<<++>>||<<-->>||<<==>>||<<++>>||

bwalker@marlin.NOSC.MIL (Beth Walker) (09/22/88)

>I have a stack in which I would like to automatically create a card button
>on each new card (and no, a background button is not a better solution;
>details on request).  

In spite of this, I do have a method using a background button.  My problem 
was that I wanted a button on each new card to be used as a check box.  Just 
creating a checkbox button in the background resulted in the check showing up 
on all cards in the stack, regardless of which card the button was clicked on.

My solution was to create a button and field pair in the background.  The 
field is set to its smallest size by dragging, and the font is set to Geneva 
10 pitch, bold.  The field was named according to its function -- PAID, etc.  
I then create a transparent button, also in the background, and place it over 
the field.  The script of the button is as follows:

   get first word of bkgnd field "PAID"
   if it is empty then
      put "X" into it
   else
      put empty into it
   end if 
   put it into first word of bkgnd field "PAID"
 
I now have a button that will put an X into the field when it is clicked.  If 
the button is clicked again, the X is removed.  The button shows up on every 
new card, but the X only appears on those cards for which the button is 
clicked.

Now, if anyone knows of an easier way to do this....

cca@pur-phy (Charles C. Allen) (09/22/88)

This brings up a point people have commented on before.  Notice that
the text for a background field is local to each card, while the
highlight state of a background button is global.  Basically, it would
be nice if the "state" of a background button or field was a property
that could be marked as local or shared.

That's easy (right, Dan? :-).  Now how about sharing scripts between
different cards/fields/buttons/whatever?  Having to update N different
scripts (all the same) can be painful at times, besides being wasteful
of space.

Charlie Allen		   cca@newton.physics.purdue.edu

dan@Apple.COM (Dan Allen) (09/22/88)

In article <1455@pur-phy> cca@pur-phy (Charles C. Allen) writes:
>That's easy (right, Dan? :-).  Now how about sharing scripts between
>different cards/fields/buttons/whatever?  Having to update N different
>scripts (all the same) can be painful at times, besides being wasteful
>of space.

Why do you have N different copies of the same script?  If it is really
the same, then it should be in some shared location like the stack
script and thus used by all cards, fields, buttons, etc.

Dan Allen
Apple Computer

c60b-bh@buddy.Berkeley.EDU (Robert Menke) (09/23/88)

In article <1080@marlin.NOSC.MIL> bwalker@marlin.nosc.mil.UUCP (Beth Walker) writes:

>Now, if anyone knows of an easier way to do this....


How about using the method that is in your Stack Ideas stack on the card
labeled (I believe) Image Index?

The idea is to use standard check boxes and a hidden field to store the
status of each of the check buttons.

Then the background script would read something like:

on openCard
  repeat with i = <firstButton#> to <lastButton#>
    set the hilite of bkgnd button i to (line i of field "Stats" = "true")
  end repeat
end openCard

on closeCard
  repeat with i = <firstButton#> to <lastButton#>
    put the hilite of bkgnd button i into line i of field "Stats"
  end repeat
end closeCard

Only problem is that this is SLOOOOOW (especially if you have 40 buttons
per card like myself). Locking the screen helps.

Perhaps an XCMD could speed things up...

						--Rob

	REAL Mac programmers can read PICT resources without IM V.
How Wabewalker became one with the net:  |
    >LOGIN                               | Robert Menke
    >TYPE "RN COMP.SYS.MAC"              |   c60b-bh@buddy.berkeley.EDU
    >READ ARTICLES                       |