TweetFollow Us on Twitter

AutoHyperEdit
Volume Number:4
Issue Number:7
Column Tag:HyperChat™

Auto Hyper Edit Moves in Groups

By Fred Stauder, HyperChat Editor, Zurich, Switzerland

AutoHyperEdit

Over the last few months we have seen the evolution of Hypercard Stacks. We have also been evolving AutoScriptEdit by showing you how to increase the functionality while retaining simplicity. I have had a lot of feedback about ASE and most people prefer it to the inbuilt shortcuts in Hypercard 1.2.

So what was I to do for an encore, well I always wanted to group and move buttons etc. Souix Lacey did a great job with Groupies, and I wondered if I could make Hypercard act more in a Mac way. I decided to write AutoHyperEdit.

Well I started experimenting and I was thoroughly addicted to solving the problem. Even half way throug writing it I thought it would be impossible to get around some obstacles that would make it work. The script basically allows the user to shift and click on objects to group them. The problem was if you clicked on a button for example after my stack had done it’s stuff it would then execute the button that was clicked on. So I couldn’t use nice things like target. The way I got around that was to check what objects were under the mouse at the time of the shiftKey.

After I had the scripting finished I decided I would make a model Installer and Demo Stack. I will first take you through the Stack and then get into how and what was done.

figure 1. AutoHyperEdit

The opening card shows what a little shading can do to add depth to your stack. The buttons I created to give as much feedback as possible. When you click on a button it appears to move in and the center black square turns to white. This is done by switching icons. Also to implement more feedback a click sound is heard.

I can’t stress the importance of a good user interface particularly in Hypercard. At least half of my time in this project was spent on the interface. Apple is spending a lot of dollars on interface technology and have recognised the need for using it to aid in the smooth information flow between computer and machine. There is a group at Apple called the Human Interface Group, their sole job is to work on interface ideas and guidelines. If you have not read the Human Interface Guidelines do so immediately. It is a must. The guidlines are available through APDA and in some Bookshops and Computer Stores.

If you go to the examples card you will see three new buttons; “Script Tools”, “Object Tools” and “Aligning Tools”.

figure 2.

The Script Tools are the tools found in AutoScriptEdit-III. I use an interesting way to demo how the tools are to be used. There is part of a keyboard and part of a mouse pad and a mouse in the bottom left of the card, see figure 3.

figure 3.

When you click on a selection, you also get visual and auditory feedback, a field pops up along with two buttons; “Close” and “Show Me”.

figure 4.

Clicking on “Show Me” Starts the demo. First the cursor dissapears and an icon that is identical to the cursor is shown at the point of interest. To attract the attention to the moving parts I “flash” (hilite/unhilite) both the cursor and the the mouse icon. now I play the tune:

play harpsichord tempo 1200 c5 c6 c7

This signifies the start of what you should do. I then play the word “mousedown” which has been digitized. The icon changes showing a mouse with the button down. I showed the original demo’s to non Mac users and they could follow how to do it easily. My previous tests where I didn’t have all the feedback the user was a bit lost and did not know where to focus his attention. The rest of the demo shows the “mouse” and the “cursor” moving up above a field. The script editor is then evoked.

The Object Tools shows buttons; “Grouping”, “Moving”, “Copying”, and “Clearing” see figure 5.

figure 5.

The action of the buttons remain consistent even though the location is slightly different. One of the things to watch out for in your stacks is to keep consistency and simplicity at the forefront of your mind when you are designing.

The demo of grouping shows the tool window first to show that you must be in the browse tool mode. You then click on an object with the shift key down. This will hilite a button.

figure 6

There was a problem of not being able to hilite a field, so as well as a hilite I use a click tone. To select more objects just shift click again and to de-select you also shift click. Once you have finished selection you must double click not on an object. This will bring you to the button tool where you can choose a menu item such as “copy button”. Or simply type command-C. I used a feature of Hypercard 1.2 to show the card picture. I have a menu as a card picture and I show it and drag a hilited transperent button to act as a regular menu, see figure 7. Now go to the card you want to paste to and do a command-V and the objects will appear.

figure 7.

Clearing objects works in the same way, first selection then, double click, then menu command.

The next section is Aligning Tools. This allows you to select objects as before and then to hold down the mouse where you want the objects to be aligned, press the arrow key which corresponds to the alignment i.e. left arrow align left.

figure 8.

I also created an installer that puts the script into your home stack and adds a checkbox in the preferences card to allow you to turn AHE on and off. I do this in an interesting way. As well as the checkbox I add a hidden field to the card. I put the home stack into the field and search for specific comment strings that are on the same line as the handlers and I comment out the begining and end of the handlers.

{1}
on mouseUp
  if the hilite of me is false
  then
    put the script of this stack  into cd fld “TempAHE”
    lock screen
    show cd fld “TempAHE”
    repeat 8 times
      set cursor  to busy
      find “--**AutoHyperEdit**--”
      put the foundline into temp
      select temp
      put “--” before the selection
      put the selection into temp
    end repeat
    set script of this stack to cd fld “TempAHE”
    put empty into cd fld “TempAHE”
    hide cd fld “TempAHE”
    unlock screen
  else
    put the script of this stack  into cd fld “TempAHE”
    lock screen
    show cd fld “TempAHE”
    repeat 8 times
      set cursor  to busy
      find “--**AutoHyperEdit**--”
      put the foundline into temp
      select temp
      put the selectedtext into stext
      delete char 1 to 2 of stext
      put stext into the selection
      put stext into temp
    end repeat
    set script of this stack to cd fld “TempAHE”
    put empty into cd fld “TempAHE”
    hide cd fld “TempAHE”
    unlock screen
  end if
end mouseUp

The Remove card simply removes all traces of AHE.

Here is the script I will go through the important parts and tell you what they do.


{2}
---- AutoHyperEdit 1.0  by Fred Stauder  June 1988 ----

-- Put this Script into your Home Stack
-- To use keep mouse btn down over Button or Field and move mouse up
-- To edit Bkgnd Script keep mouse btn down move mouse to -left of card
-- Card Script - move right
-- Stack Script - move up
-- Now works with unlocked fields
-- To lock and unlock fields option click in them
-- To show/hide tools/patterns at cursor
-- hold option click on non-field areas
-- click in top left to hide cd window botom right to show
--Group objects by shift clicking in browse tool
--Move objects by holding mouse down and draging
--Copy and Clear groups of objects after selecting by using menus
-- Align objects after selecting, hold mouse down at align loc and press
-- the arrow key i.e. align left use left arrow key
-- Turn AHE on and Off using the  Checkbox installed in the Pref Card 
of Home

The globals are CWSlist is where the selected objects id’s are cwloc is the card window location to hide the card and selectcomp is a flag for when the selections are compleated.

Gobo resets the hilites and puts empty into CWSList. The first section is AutoScriptedit Stuff.

{3}
on mouseStillDown --**AutoHyperEdit**--
  Global cwslist,cwLoc,selectcomp
  if selectcomp is “true” then gobo
  
  put empty into CWSList
  
  if the optionkey is down
  then
    if the target contains “field” then set locktext of target to false
    else
      if the optionkey is down then
        set the visible of pattern window to not the visible of pattern 
window
        set the loc of pattern window to the mouseloc
        set the visible of tool window to not the visible of tool window
        set the loc of tool window to the mouseloc
        exit mouseStillDown --------
      end if
    end if
  end if
  if the mouseloc is within “0,0,10,10”
  then
    put the loc of card window into CWLoc
    set loc of card window to -504,-315
    exit mousestilldown
  end if
  if the mouseloc is within “500,333,512,346”
  then
    set loc of card window to CWLoc
    exit mouseStillDown
  end if
  put char 6 of the target into C6
  if C6 is quote then AutoScriptEdit
  if C6 is “i” then AutoScriptEdit
  if C6 is quote then exit mousestilldown
  if C6 is “i” then exit mousestilldown
  if the mouseV <item 2 of rect of target then edit script of target
  else
    ------------------CWS
    put empty into foundit
    put false into offdetected
    if cwslist is empty
    then
      if the shiftkey is down
      then
        repeat until offdetected is true
          if the shiftkey is down
          then
            shiftselect

Here we go to the routine that selects objects.

{4}
            put false into foundit
          else
            movegroup
            wait until the mouse is down
            repeat with y = the number of items in CWSlist down to 1
              if the mouseloc is within the rect of item y of cwslist
              then
                put false into foundit
                exit repeat
              else
                put true into foundit
              end if
            end repeat
          end if
          if foundit is true
          then if the shiftkey is up then put true into offdetected
        end repeat
        
        choose btn tool
        select item 1 of cwslist
        put “true” into selectcomp
      end if
    end if
  end if
  --pass mouseStillDown
end mouseStillDown --**AutoHyperEdit**--


on AutoScriptEdit
  if the mouseH < 2   then edit script of this bkgnd
  if the mouseH > 510 then edit script of this card
  if the mouseV < 2   then edit script of this stack
end AutoScriptEdit

on openfield --**AutoHyperEdit**--
  if the optionkey is down
  then
    if the mouseV <item 2 of rect of target
    then
      edit script of target
      set locktext of target to false
      exit openfield
    end if
    set locktext of target to true
  end if
  pass openfield
end openfield --**AutoHyperEdit**--

This traps the menu selections so that copy buttons etc will work on groups of objects

{5}
on domenu stuff --**AutoHyperEdit**--
  global WhatsMyCardName,CWSList,selectcomp
  if selectcomp is true
  then
    if  stuff is “clear button”
    then
      clrobj
      exit domenu
    else if stuff is “Copy Button” then
      put the long name of this card into WhatsMyCardName
      pass domenu
    else if stuff is “cut button” then put tip into top
    else if stuff is “paste button” then
      pasteobj
      exit domenu
    else if stuff is “Copy field”then
      put the name of this card into WhatsMyCardName
      pass domenu
    else if stuff is “paste field” then pasteobj
    else if stuff is “clear field” then clrobj
    pass domenu
    exit domenu
  end if
  pass domenu
end domenu --**AutoHyperEdit**--

This is the Object clearing routine.

{6}
on clrobj
  global CWSList
  lock screen
  repeat with p= the number of items in CWSlist down to 1
    set cursor to busy
    put item p of CWSlist into it
    select it
    type “x” with commandkey
  end repeat
  choose browse tool
  unlock screen
  put empty into Cwslist
end clrobj

This is the object pasting routine

{7}
on pasteobj
  global CWSList,WhatsMyCardName,selectcomp
  put false into selectcomp
  set lockscreen to true
  set lockmessages to true
  repeat with x= the number of items in CWSlist down to 1
    if second word of item x of CWSList ¬
    is “field” then choose field tool else choose btn tool
    set cursor to busy
    push card
    go to WhatsMyCardName
    put item x of CWSlist into it
    if second word of it is “btn” then set hilite of it to false
    if first word of it is “btn” then set hilite of it to false
    select it
    type “c” with commandkey
    pop card
    if first word of it is “Bkgnd” then type “b” with cmdkey
    type “v” with commandkey
    if first word of it is “Bkgnd” then type “b” with cmdkey
  end repeat
  choose browse tool
  set lockscreen to false
  set lockmessages to false
  put empty into CWSlist
  put empty into WhatsMyCardName
  put false into selectcomp
  choose browse tool
end pasteobj

on gobo
  global CWSList,turnoff,selectcomp
  repeat with x= the number of items in CWSlist down to 1
    if second word of item x of CWSList is “btn” then set the hilite 
of item x of CWSlist to not the hilite of item x of CWSlist
    if first word of item x of CWSList is “btn” then set the hilite of 
item x of CWSlist to not the hilite of item x of CWSlist
  end repeat
  put empty into CWSList
end gobo

Here I had to test for different objects. I tried to put “if the mouseloc is within the rect of a variable then....” where the variable contained an objuct such as btn and another variable. This did not work it is a pity I could have cut the script down considerably. Because of this I have to handle the object types seperately.

{8}
on shiftselect
  global CWSlist,w,x,y,z
  repeat until the shiftkey is up
    repeat while the mouse is down
      repeat with w = the number of cd btns down to 1
        if the mouseloc is within the rect of btn w then HITCBtn
      end repeat
      repeat with x = the number of bkgnd btns down to 1
        if the mouseloc is within the rect of bkgnd btn x then HITBBtn
      end repeat
      repeat with y = the number of cd flds down to 1
        if the mouseloc is within the rect of cd fld y then HITCFld
      end repeat
      repeat with z = the number of bkgnd flds down to 1
        if the mouseloc is within the rect of bkgnd fld z then HITBFld
      end repeat
    end repeat
  end repeat
end shiftselect

on HitBFld
  global CWSlist,z
  put false into foundit
  if the commandkey is down then set the visible of bkgnd fld z to not 
the visible of bkgnd fld z
  if the number of items in CWSlist =0
  then
    put “Bkgnd field id “ & the id of Bkgnd fld z & “,”after CWSList
    play harpsichord tempo 100 b#x7
    exit HitBFld
  end if
  repeat with p = the number of items in CWSlist  down to 1
    put item p of CWSList into it
    if it = “Bkgnd field id “ & the id of Bkgnd fld z
    then
      delete item p of CWSList
      play harpsichord tempo 100 b#x7
      exit HitBFld
    end if
  end repeat
  put “Bkgnd field id “ & the id of bkgnd fld z & “,”after CWSList
  play harpsichord tempo 100 b#x7
end HitBFld

on HitCFld
  global CWSlist,y
  put false into foundit
  if the commandkey is down then set the visible of cd fld y to not the 
visible of cd fld y
  if the number of items in CWSlist =0
  then
    put “Card field id “ & the id of cd fld y & “,”after CWSList
    play harpsichord tempo 100 b#x7
    exit HitCFld
  end if
  repeat with p = the number of items in CWSlist  down to 1
    put item p of CWSList into it
    if it = “Card field id “ & the id of cd fld y
    then
      delete item p of CWSList
      play harpsichord tempo 100 b#x7
      exit HitCFld
    end if
  end repeat
  put “Card field id “ & the id of cd fld y & “,”after CWSList
  play harpsichord tempo 100 b#x7
end HitCFld

on HitBBtn
  global CWSlist,x
  put false into foundit
  if the commandkey is down then set the visible of bkgnd btn x to not 
the visible of bkgnd btn x
  set the hilite of bkgnd btn x to not the hilite of bkgnd btn x
  if the number of items in CWSlist =0
  then
    put “bkgnd btn id “ & the id of bkgnd btn x & “,”after CWSList
    play harpsichord tempo 100 b#x7
    exit hitBBtn
  end if
  repeat with p = the number of items in CWSlist  down to 1
    put item p of CWSList into it
    if it = “bkgnd btn id “ & the id of bkgnd btn x
    then
      delete item p of CWSList
      play harpsichord tempo 100 b#x7
      exit hitBBtn
    end if
  end repeat
  put “bkgnd btn id “ & the id of bkgnd btn x & “,”after CWSList
  play harpsichord tempo 100 b#x7
end HitBBtn

on HitCBtn
  global CWSlist,w
  put false into foundit
  if the commandkey is down then set the visible of btn w to not the 
visible of btn w
  set the hilite of btn w to not the hilite of btn w
  if the number of items in CWSlist =0
  then
    put “btn id “ & the id of btn w & “,”after CWSList
    play harpsichord tempo 100 b#x7
    exit hitCBtn
  end if
  repeat with p = the number of items in CWSlist  down to 1
    put item p of CWSList into it
    if it = “btn id “ & the id of btn w
    then
      delete item p of CWSList
      play harpsichord tempo 100 b#x7
      exit hitCBtn
    end if
  end repeat
  put “btn id “ & the id of btn w & “,”after CWSList
  play harpsichord tempo 100 b#x7
end HitCBtn

This section moves the objects.

{9}
on movegroup
  global CWSList
  wait until the mouse is down
  put the mouseLoc into mLoc
  put empty into mH
  put empty into mV
  repeat with i = 1 to the number of items in CWSList
    put item i of CWSList into iList
    put item 1 of the loc of iList - item 1 of mLoc & “,” after mH
    put item 2 of the loc of iList - item 2 of mLoc & “,” after mV
  end repeat
  repeat while the mouse is down
    get the mouseLoc
    lock screen
    repeat with i = 1 to the number of items in CWSList
      put it into iList
      add item i of mH to item 1 of iList
      add item i of mV to item 2 of iList
      set loc of item i of CWSList to iList
    end repeat
    unlock screen
  end repeat
end movegroup

I added this section very quickly because I already had the underlying selection and moving structures. As you can see it is very simple.

{10}
on arrowkey whichkey
  global CWSList
  if the mouse is down then
    if whichkey = “left” then
      put the mouseH into L
      repeat with i = 1 to the number of items in CWSList
        put the width of item i of Cwslist into w
        set the left of item i of Cwslist to L
        set the width of item i of Cwslist to w
      end repeat
    end if
    
    if whichkey = “right” then
      put the mouseH into R
      repeat with i = 1 to the number of items in CWSList
        put the width of item i of Cwslist into w
        set the right of item i of Cwslist to R
        set the width of item i of Cwslist to w
      end repeat
    end if
    
    if whichkey = “up” then
      put the mouseV into T
      repeat with i = 1 to the number of items in CWSList
        put the height of item i of Cwslist into h
        set the top of item i of Cwslist to T
        set the height of item i of Cwslist to h
      end repeat
    end if
    
    if whichkey = “down” then
      put the MouseV into B
      repeat with i = 1 to the number of items in CWSList
        put the height of item i of Cwslist into h
        set the bottom of item i of Cwslist to B
        set the height of item i of Cwslist to h
      end repeat
    end if
    exit arrowkey
  end if
  pass arrowkey
end arrowkey --**AutoHyperEdit**--
Non-Comercial use only - All Rights Reserved
Fred Stauder, Hypercard Editor, (HyperChat) MacTutor
---- AutoHyperEdit by Fred Stauder, June 1988 ---

You should get the stack because of the animation and sound ideas it contains. The key thing is to plan your stacks keep them modular so that they can be added to and be polite and use the pass statement so that other peoples scripts will work. For example a stack that uses on mouseStillDown and does not pass it will stop AutoHyperEdit working in that Stack.

Send your Articles, ScriptTips, SpeedTips, etc. to:

Fred Stauder, AppleLink D0280

Ecofin Reseach and Consulting

Lavaterstrasse 45

Zurich 8002

Switzerland

or

To the MacTutor Office

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Ys Chronicles II (Games)
Ys Chronicles II 1.0.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0.0 (iTunes) Description: After a hard fight to recover the six sacred books in Ys Chronicles I, Adol is back for a sequel! | Read more »
FINAL FANTASY Ⅸ (Games)
FINAL FANTASY Ⅸ 1.0.4 Device: iOS Universal Category: Games Price: $16.99, Version: 1.0.4 (iTunes) Description: ==========●Special sale price for the FINAL FANTASY IX release! ●20% off from February 10 to February 21, 2016... | Read more »
Tennis Club Story (Games)
Tennis Club Story 1.03 Device: iOS Universal Category: Games Price: $4.99, Version: 1.03 (iTunes) Description: Aim for the ace position of tennis club prestige in this simulation! Your leadership decides if players make it to the big... | Read more »
Juggernaut Wars guide - How to use skill...
Juggernaut Warsis a brand new auto-RPG on iOS and Android that challenges you to build a team of heroes, send them out into various different missions to defeat waves of heroes, and level them up to increase their power. The actual combat itself... | Read more »
Check out the new Pirate Attack update i...
Love pirates and board games? Well, you'll love the new Pirate Attack themed update that just launched in Game of Dice. It adds a bunch of new content themed around pirates, like an all new event map based on a pirate ship which revamps the toll... | Read more »
Splash Cars guide - How to paint the tow...
Splash Cars is an arcade driving game that feels like a hybrid between Dawn of the Plow and Splatoon. In it, you'll need to drive a car around to repaint areas of a town that have lost all of their color. Check out these tips to help you perform... | Read more »
The best video player on mobile
We all know the stock video player on iOS is not particularly convenient, primarily because it asks us to hook a device up to iTunes to sync video in a world that has things like Netflix. [Read more] | Read more »
Four apps to help improve your Super Bow...
Super Bowl Sunday is upon us, and whether you’re a Panthers or a Broncos fan you’re no doubt gearing up for it. [Read more] | Read more »
LooperSonic (Music)
LooperSonic 1.0 Device: iOS Universal Category: Music Price: $4.99, Version: 1.0 (iTunes) Description: LooperSonic is a multi-track audio looper and recorder that will take your loops to the next level. Use it like a loop pedal to... | Read more »
Space Grunts guide - How to survive
Space Grunts is a fast-paced roguelike from popular iOS developer, Orange Pixel. While it taps into many of the typical roguelike sensibilities, you might still find yourself caught out by a few things. We delved further to find you some helpful... | Read more »

Price Scanner via MacPrices.net

Apple restocks Certified Refurbished Mac mini...
Apple has restocked Certified Refurbished 2014 Mac minis, with models available starting at $419. Apple’s one-year warranty is included with each mini, and shipping is free: - 1.4GHz Mac mini: $419 $... Read more
What iPad Pro Still Needs To Make It Truly Pr...
I love my iPad Air 2. So much that I’m grudgingly willing to put up with its compromises and limitations as a production tool in order to take advantage of its virtues. However, since a computer for... Read more
21-inch 3.1GHz 4K on sale for $1399, $100 off...
B&H Photo has the 21″ 3.1GHz 4K iMac on sale $1399 for a limited time. Shipping is free, and B&H charges NY sales tax only. Their price is $100 off MSRP: - 21″ 3.1GHz 4K iMac (MK452LL/A): $... Read more
Apple price trackers, updated continuously
Scan our Apple Price Trackers for the latest information on sales, bundles, and availability on systems from Apple’s authorized internet/catalog resellers. We update the trackers continuously: - 15″... Read more
Save up to $240 with Apple Certified Refurbis...
Apple is now offering Certified Refurbished 12″ Retina MacBooks for up to $240 off the cost of new models. Apple will include a standard one-year warranty with each MacBook, and shipping is free. The... Read more
Apple refurbished 13-inch Retina MacBook Pros...
Apple has Certified Refurbished 13″ Retina MacBook Pros available for up to $270 off the cost of new models. An Apple one-year warranty is included with each model, and shipping is free: - 13″ 2.7GHz... Read more
Apple refurbished Time Capsules available for...
Apple has certified refurbished Time Capsules available for $120 off MSRP. Apple’s one-year warranty is included with each Time Capsule, and shipping is free: - 2TB Time Capsule: $179, $120 off - 3TB... Read more
13-inch 2.5GHz MacBook Pro (refurbished) avai...
Apple has Certified Refurbished 13″ 2.5GHz MacBook Pros available for $829, or $270 off the cost of new models. Apple’s one-year warranty is standard, and shipping is free: - 13″ 2.5GHz MacBook Pros... Read more
Apple refurbished 15-inch Retina MacBook Pros...
Apple has Certified Refurbished 2015 15″ Retina MacBook Pros available for up to $380 off the cost of new models. An Apple one-year warranty is included with each model, and shipping is free: - 15″ 2... Read more
New Liquid Crystal Technology Prevents Automo...
Researchers at the University of Central Florida have developed three new liquid crystal mixtures which will allow automobile displays to operate at unprecedented high and low temperatures In... Read more

Jobs Board

Lead Engineer - *Apple* OSX & Hardware...
Lead Engineer - Apple OSX & Hardware **Job ID:** 3125919 **Full/Part\-Time:** Full\-time **Regular/Temporary:** Regular **Listed:** 2016\-02\-10 **Location:** Cary, Read more
*Apple* System Analyst - ATOS IT Services...
Apple System AnalystReference no.198783CountryUSARegionUS - CALIFORNIACityUS - CALIFORNIA - BURBANKPosition TypeProfessionalJob AreaIT SupportJob TypeFull Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
*Apple* Subject Matter Expert - Experis (Uni...
This position is for an Apple Subject Matter Expert to assist in developing the architecture, support and services for integration of Apple devices into the domain. Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.