A floating palette/window can be successfully faked with a button
substituting for the titlebar. Clicking on the button will
drag a group of objects around the card window. The technique
can be implemented as a generic command by passing the objects
as a string of object reference items.
Example: Trap an event within the titlebar button "MyButton"...
on mouseStillDown
moveObjects "cd btn MyButton,cd fld MyField"
end mouseStillDown
... and move the objects with a generic handler somewhere in the
message-passing hierarchy.
on moveObjects objectList
put the mouseLoc into startLoc
repeat while the mouse is DOWN
put the mouseLoc into endLoc
put subtractVectors(endLoc,startLoc) into vector
lock screen
repeat with i = 1 to (the number of items in objectList)
set the topLeft of item i of objectListå
to addVectors(the topLeft of item i of objectList,vector)
end repeat
unlock screen
put endLoc into startLoc
end repeat
end moveObjects
function addVectors v1,v2
return ((item 1 of v1) + (item 1 of v2))&","å
&((item 2 of v1) + (item 2 of v2))
end addVectors
function subtractVectors v1,v2
return ((item 1 of v1) - (item 1 of v2))&","å
&((item 2 of v1) - (item 2 of v2))
end subtractVectors
In order to build several "views" onto a single background, one can use
shared text fields as labels and the script below to toggle which view
is visible. This is useful when there are lots of fields on a
particular bg.
For each button or field that is a member of one or more views, insert
-- scr 1,2 etc
into the first line of the its script.
Then insert this handler in the bg, adding an if then for bg buttons as
well:
on showscreen which
lock screen
repeat with k = 1 to the number of bg fields
put line 1 of the script of bg fld k into chking
if cking contains "scr" then
if cking contains which then
show fld k
else
hide fld k
end if
end if
end repeat
unlock screen
-- don't forget the color update handler if fields are colorized.
end showscreen
This allows the developer to arrange fields into views "on the fly",
since the toggle view button script is simple:
on mouseup
showscreen 2
end mouseup
This technique also allows the developer to insert "admin screens" that
allow troubleshooting of otherwise hidden fields.Jay Fogleman
Tab takes the cursor to the next unlocked field, so you can exclude some fields from tabbing by locking them. By extension, you can take virtually absolute control of tabbing order by locking all fields but the one you want to go to. Then place returnInField/enterInField logic in the field(s) to lock the field, unlock the next field you want to go to, and send tabKey to HyperCard. This technique allows the scripter to control which fields the user can access and the order in which they are accessed.
Rob Cozens
Serendipity Software Company
This undocumented feature allows HyperCard to display black and white pictures that act like icons. First, you have to create and name a picture resource (B&W needed). Then create a button. Then set the name of the button to the title of the PICT resource. Now, use the message box or a script to set the icon of the button to ID -1. Now the button should be a picture! The picture doesn't have a mask (it's opaque) so watch out! You can move the button around and the picture will follow.
Kevin .Marshall
CEO, ResNamen Software
The autoHilite feature of picture buttons won't work while the PICT is displayed. Picture buttons were inadvertently left out of the HyperCard 2.1 Player.
Paul Foraker
White Feather Software
One way of copying multiple items is through Super Grouper in the Power Tools stack. Did you know that you can hold down the Option key when you click the grouping button and get a cross-hair cursor for dragging a region?
Paul Foraker
White Feather Software
The selectedLine of a list field is perdurable. That is, if you make a field a list field, select a line, then make it not a list field, the selectedLine of the field still returns the previously selected line number. The key is locking and unlocking the field. If the field is locked (and its autoSelect is true), it's a list field. Selecting a line puts that line number in the perdurable property of the list field. If you unlock the field and select a different line, the selectedLine of the field will still return the original line number. The solution is to make the field a list field, select line 0, make it not a list field, and only then run your scripts. If you select line 0 of a non-list field field, the selectedLine is actually line 1 to 1...
Paul Foraker
White Feather Software
a neat new wrinkle to the -1 trick. make color artwork which also looks ok in BW. do the -1 thing. Make your button exactly the rect of the color artwork. on mouseDown or mouseUp do this: set the icon of me to 0 addColor colorButton, cd,"pict name here", the rect of me, stamp, 0 set the icon of me to -1 mess around with the order of these commands on mouseDown, mouseUp until it goes ok, I am writing this on the fly... it might be better to leave the color picture there to begin with, and hilite with the bw version. on close card or something make sure to reset the button to -1, just in case. what happens is more or less a color picture hilite. the picture will last ONLY until a call to addColor colorCard and is not permanent.... so watch it.
You can move text from one field to another, preserving style
information, using AppleScript. Try some variation on this in an
AppleScript button:
on mouseUp
copy field "Foo" to textWithStyles
go card "Bar"
copy textWithStyles to field "Foo"
end mouseUp
No XCMDs needed, but you do need HC 2.2 or better and AppleScript.
1. create a series of icons to "animate" using Hypercard's icon editor.
2. invert the icons. In other words, the white pixels are the ones
which will be colored.
3. color the button the color that you want to give to the icons, using
addColor. The color will show through the white pixels in the icon.
4. place the icon in a black area of the card, for example a black
header, title, footer, etc.
5. place a script in your card script:
on idle
global currentIcon, firstIcon, lastIcon, lastTime
if firstIcon is empty then put 400 into firstIcon -- this is arbitrary
if lastIcon is empty then put 410 into lastIcon -- ditto
if currentIcon is empty then put firstIcon into currentIcon
if lastTime is empty then put the ticks into lastTime
if lastTime - 60 >= the ticks then -- wait 1 second between frames
put the ticks into lastTime
if currentIcon = lastIcon then
put firstIcon into currentIcon
else
add 1 to currentIcon
end if
set the icon of cd btn "icon button" to currentIcon -- arbitrary
button
end if
end idle
6. When the icon changes, it will do so in color, as the color will
always fill the white space in the button. I've used this to animate a
beating heart for example.Brian Yennie
 
 
All contents copyright (C) 1996, HyperActive Software. All rights reserved.
Revised: February 4, 2002
URL: http://www.hyperactivesw.com/readertips/hctips.html