[comp.sys.mac.hypercard] selecting contents of a locked field

moore@cs.washington.edu (Charles Moore) (10/14/89)

I've got a couple of problems that I wonder if somebody has solutions
to.  I would like to have an index card in a stack that lists all the
other cards in the stack by the contents of some identifying field.  I
would like to be able to go to any listed card directly from the index
and I would like to request the deletion of any listed card without
leaving the index.  It seems to me that the natural way to do this
(for the user) would be to have a single click on a card name result
in the selection of that name whereupon the user might hit the Delete
key or click a "Delete Card" button.  To go to a listed card the user
would double-click on the name.

     This brings up my two problems.  First, the only way to select
the contents of a field seems to be by tabbing into it either with the
Tab key or with the tabKey command.  Unfortunately, this only works if
the field is unlocked.  But if I unlock it in order to select it, I
can't catch the second click of a double-click.  So, does anybody know
of a non-XCMD way of selecting the contents of a field but leaving it
locked or, alternatively, of the availability of an XCMD that will do
this?

     Secondly, is there a way to catch the Delete key?

     Any suggestions will be appreciated.

					Charles Moore

sirkm@ssyx.ucsc.edu (Greg Anderson) (10/16/89)

In article <9490@june.cs.washington.edu> moore@cs.washington.edu (Charles Moore) writes:
>I would like to have an index card in a stack that lists all the
>other cards in the stack by the contents of some identifying field.  I
>would like to be able to go to any listed card directly from the index
>and I would like to request the deletion of any listed card without
>leaving the index.

The HyperUnix read mail stack does something like that.  You might want
to take a look at it.  (ftp to ssyx.ucsc.edu.)

>It seems to me that the natural way to do this
>(for the user) would be to have a single click on a card name result
>in the selection of that name whereupon the user might hit the Delete
>key or click a "Delete Card" button.  To go to a listed card the user
>would double-click on the name.

In HyperUnix, a single-click goes to the entry in question; the user
must shift-click to select.  This makes the index more like a list
manager object, but perhaps the method you suggest would be more
intuitive.

The technique I used can impliment either method, however.

I do not worry about unlocking or selecting the field; I simply
placed numerous transparant buttons over the field in question.
The buttons are NOT autohilite; when they recieve a mouseDown,
they set their own hilite atribute if the shift key is down or
jump to the appropriate card if it is not.  It would be just as
easy to jump to another card if the button is already hilited, or
hilite it if it is unselected; however, you would then need a
method to unselect the buttons.  It would probably be best to
accomplish this by saving the tick count of when the mouseUp event
came in (and on which button it was recieved).  Double-clicks
(a second click on the same button close in time to the first click)
would then go to the card in question, while a single-click would
unselect the item again.

My only complaint with this method is that things get wierd if
you scroll a scrolling field behind a hilited button.  Try it
and see what happens.

  ___\    /___               Greg Anderson              ___\    /___ 
  \   \  /   /         Social Sciences Computing        \   \  /   /
   \  /\/\  /    University of California, Santa Cruz    \  /\/\  /
    \/    \/              sirkm@ssyx.ucsc.edu             \/    \/

sho@maxwell.physics.purdue.edu (Sho Kuwamoto) (10/16/89)

In article <9490@june.cs.washington.edu> moore@cs.washington.edu (Charles Moore) writes:
>I've got a couple of problems that I wonder if somebody has solutions
>to.  I would like to have an index card in a stack that lists all the
>other cards in the stack by the contents of some identifying field.  I
>would like to be able to go to any listed card directly from the index
>and I would like to request the deletion of any listed card without
>leaving the index.  


Here's what I do in my record collection stack.

-----
on mouseUp
  findBand
end mouseUp

on findBand
  set cursor to busy
  put (item 2 of the clickLoc) - (item 2 of the rect of field "Band Names") + the scroll of field "Band Names" into whichBand
  put (whichBand DIV textHeight of field "Band Names")+1 into whichBand
  select line whichBand of field "Band Names"
  put line whichBand of field "Band Names" into whichBand
  
  lock screen
  
  set cursor to busy
  go to first card of background "Record"
  find whole whichBand in field 1
  set cursor to busy
  if the result is not "not found"
  then
    unlock screen with iris open
  else
    go to card "root"
    unlock screen
    answer "Didn't find album by"&& whichBand & "." with "Fix list" or "Cancel"
    if it is "Fix list" then sortCards
  end if
end findBand
----
In your case, I would just delete the part of the script that does the
actual action, and keep the part that finds the line number and selects
the line.  You'll have to keep a global variable around for the last
line number selected, and the time at which it was selected in ticks.

You could also keep a hidden field with the ID numbers already
in it.  Calculate the line number, and find the appropriate ID number
to go to.

-Sho
--
sho@physics.purdue.edu  <<-- hypercard novice.

tim@hoptoad.uucp (Tim Maroney) (10/16/89)

In article <9490@june.cs.washington.edu> moore@cs.washington.edu
(Charles Moore) writes:
>I would like to have an index card in a stack that lists all the
>other cards in the stack by the contents of some identifying field.  I
>would like to be able to go to any listed card directly from the index
>and I would like to request the deletion of any listed card without
>leaving the index.  It seems to me that the natural way to do this
>(for the user) would be to have a single click on a card name result
>in the selection of that name whereupon the user might hit the Delete
>key or click a "Delete Card" button.  To go to a listed card the user
>would double-click on the name.
>     This brings up my two problems.  First, the only way to select
>the contents of a field seems to be by tabbing into it either with the
>Tab key or with the tabKey command.

It's trivial.  Install a mouseDown handler in the field that unlocks
the field, and drags from the left edge of the field to the right edge
of the field, then locks it again.  You can get the right and left edge
coordinates from "the rect of it".  Use the click coordinate ("the
clickLoc") for the vertical portion.  Then your second mouseDown event
can be picked up and checked for double-clickiness.

I have a problem with the way you're phrasing this, though.  It seems
you expect to have a single field for each card from your tab
comments.  This puts an arbitrary limit on how many cards you can have;
since you're allowing the user to delete cards, I assume you're also
letting them be added.  Wouldn't a scrolling field of card names make
more sense?  I've done this (single-click to go to card, no delete
from index) and it's pretty easy.

>     Secondly, is there a way to catch the Delete key?

Not without an XCMD.  However, please be a little more user friendly
than this.  I'd be extremely pissed if I wound up deleting a card with
a press of the delete key.  Dangerous operations should always be
advertised and safeguarded; if you do write some sort of key-trapping
XCMD to do this, then at least put in a dialog asking the user to
confirm the deletion.  However, please consider carefully whether you
even *want* a keyboard shortcut to do this.  It's certainly not worth
the work, and even if it were easy to do, you would also be making it
easy for people to shoot themselves in the feet.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"I am of the opinion that my life belongs to the whole community, and as long
 as I live it is my privilege to do for it whatever I can." -- Shaw

tim@hoptoad.uucp (Tim Maroney) (10/17/89)

In article <2647@pur-phy> sho@maxwell.physics.purdue.edu.UUCP (Sho Kuwamoto)
writes:
>  select line whichBand of field "Band Names"

"Select"?  Is this some command that was added after 1.2.1?  None of my
references, including the on-line help, mentions it.

>  find whole whichBand in field 1

"Find whole"?  Ditto.  I think I had better dig up a new version.  How
many features have been added since last year, anyway?
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"Superhero stories could best be described as entertainment that externalizes
 childhood power fantasies." -- Timothy Fay on rec.arts.comics

moore@cs.washington.edu (Charles Moore) (10/17/89)

In article <8717@hoptoad.uucp>, tim@hoptoad.uucp (Tim Maroney) writes:
> However, please be a little more user friendly
> than this.  I'd be extremely pissed if I wound up deleting a card with
> a press of the delete key.  Dangerous operations should always be
> advertised and safeguarded; if you do write some sort of key-trapping
> XCMD to do this, then at least put in a dialog asking the user to
> confirm the deletion.  

First of all, thank you Tim, and others for your helpful suggestions.

Second, I understand your concern with easy deletion of anything.  Yet,
isn't the select-and-press-delete shortcut exactly what already exists
with regard to buttons, fields, or portions of text in scripts or fields?
If you select a button with the button tool and then hit the delete key,
would you really want to have a dialog box pop up asking if you really
want to do that?  Now, I admit that deletion of an entire card is a 
potentially more dangerous operation since there's more information
involved but it seems intuitive to me that if you delete the entry for
a card from a purportedly complete index to the cards that the card itself
should be deleted.  What else could deletion of the index entry mean?
Furthermore, as with buttons and fields, it's already a two-step process
(first select, then delete) and so, difficult to do accidentally.  Does
it really need to be a three-step process?

Charles

Barry.Chern@f200.n226.z1.FIDONET.ORG (Barry Chern) (10/18/89)

Tim Maroney writes:
>"Select"?  Is this some command that was added after 1.2.1?
  
I think it was already there in 1.2.1, but you should definitely get
1.2.2. These were updates with very real increases in functionality. And
be sure you get the Release Notes Stack with it.

--  
Barry Chern via cmhGate - Net 226 fido<=>uucp gateway Col, OH
UUCP: ...!osu-cis!n8emr!cmhgate!200!Barry.Chern
INET: Barry.Chern@f200.n226.z1.FIDONET.ORG