[comp.sys.mac.hypercard] using fields with scroll bars

riddle@mathcs.emory.edu (Larry Riddle) (06/21/89)

I need some help with the following problem:

I have a scrolling field with a list of names of hidden fields. When
the user clicks on one of the names, that field is made visible. 
In addition, I have a button that is moved over the line where the
click was made and then the button's hilite property is set to true.
All this works fine. However, my problem is when the user then scrolls
to see other lines in the field. As soon as the user starts to scroll,
I would like my button to become unhilited so as not to distract from
the scrolling field and ruin the visual effect. I suspect I could do
this by overlaying my own buttons on top of the scroll bar to simulate
the scrolling, but I am hoping that there might be a quicker and
easier solution. What I would really like is something like

on clicking in the scroll bar
	set hilite of btn x to false
	start the normal scrolling behavior
end clicking in the scroll bar

Any suggestions?

-- 
Larry Riddle        | riddle@mathcs.emory.edu         PREFERRED
Emory University    | {decvax,gatech}!emory!riddle    UUCP 
Dept of Math and CS | riddle@emory                    NON-DOMAIN BITNET
Atlanta, GA 30322   | (404) 727-7922                  AT&T

dlugose@ecsvax.UUCP (Dan Dlugose) (06/21/89)

In article <4161@emory.mathcs.emory.edu> riddle@mathcs.emory.edu (Larry Riddle) writes:
>In addition, I have a button that is moved over the line where the
>click was made and then the button's hilite property is set to true.
>All this works fine. However, my problem is when the user then scrolls
>to see other lines in the field. As soon as the user starts to scroll,
>I would like my button to become unhilited so as not to distract from
>the scrolling field and ruin the visual effect. I suspect I could do

   I think you'll need overlaying button(s) or field(s).  However, one
invisible button over everything could decide whether it needed to
unhilite any other buttons, and then pass the mouseup.
   Dan Dlugose
   UNC Edu. Computing Service

baum@Apple.COM (Allen J. Baum) (06/22/89)

[]
>In article <4161@emory.mathcs.emory.edu> riddle@mathcs.emory.edu (Larry Riddle) writes:
>I need some help with the following problem:
...basically, highlighting a line of a scrolling field
>Any suggestions?

I had exactly the same problem. I'm assuming you don't want more than one line
highlighted at once. I set the locktext of the scrolling field to true, so that
mouseclicks on the field send mouseup/down to the script of the field. The
script is:
  on mouseup
    set lockText of me to false --stop intercepted mouseclicks
    click at clickloc           --put text cursor in field
    select the selectedline     --use 'selectedline' function to select line
    set lockText of me true     --start intercepting mouseclicks again
   --put your action here, i.e.
    set visible of field (word 2 of the selectedline) to true
  end mouseup
You can determine the number of the line that you selected by looking at
    word 2 of the selectedline
Note that if a line wraps, both 'physical' lines will be selected.
This is fairly slow, unfortunately. I'm not sure what is taking so long,
but it may be just a bit too slow for real interactive work.

--
		  baum@apple.com		(408)974-3385
{decwrl,hplabs}!amdahl!apple!baum

baum@Apple.COM (Allen J. Baum) (06/22/89)

[]
>In article <4161@emory.mathcs.emory.edu> riddle@mathcs.emory.edu (Larry Riddle) writes:
>In addition, I have a button that is moved over the line where the
>click was made and then the button's hilite property is set to true.
>All this works fine. However, my problem is when the user then scrolls
>to see other lines in the field. As soon as the user starts to scroll,
>I would like my button to become unhilited so as not to distract from
>the scrolling field and ruin the visual effect. I suspect I could do
>

Oops, I solved the wrong problem in the last message. The problem is not
highlighting the field, but un-highlighting when you scroll. I would put
a button over the scrollbar. The button should be hidden, until the field
script is executed,. i.e.,  inside the field script should be:
   set visible of button "scrollbut" to true
Then, the button script should deselect the line in the field, and hide
itself:
 on mousedown  --note, this is a mousedown, not mouseup handler
   select char 2 to 1 of cd field "scrollfield" --unselect line
   set visible of me to false              --hide me
 end mousedown

--
		  baum@apple.com		(408)974-3385
{decwrl,hplabs}!amdahl!apple!baum

beard@wuibc.UUCP (James Beard MD) (06/23/89)

[in response to a query about how to make a click in the scroll bar of
a scrolling field un-highlight a button overlying a line of text in
the field.]

I can't be certain I understand what you are trying to do, but I would
suggest the following:

1) Perhaps you could dispense with the button entirely, if its sole
purpose is to highlight the selected line.  Version 1.2 allows you to
highlight a chunk of a field from within a script.  You can first
deduce what line of the field was clicked in.  Apple gives some
examples of this, which requires using the mouseloc at clicking time,
the height of a line of text (one of the fld properties), and how far
scrolled the field is (a fld property).  Assume that you have deduced
that the line clicked was line x.  Then you could write
  ...
  select line x of fld myField
  ... 

Besides being faster than moving a button around, this has the
advantage that the highlighted line remains highlighted (even during
scrolling out of and into view) until you do something to un-highlight it.

2) Version 1.2 has a new operator, Within, that lets you ask
whether a given point is within a certain rectangle.  An expression
of the form "<point> is within <rect>" will return a value of either
true or false.  Thus you could include something like the following in
the script of the scrolling field, assuming that you had previously
put the rect of the scroll bar into scrollzone:

on mousedown
  global scrollzone
  get the mouseloc
  if it is within scrollzone 
  then select empty  -- this undoes the highlighting
  pass mousedown  -- this lets the scroll bar do its scrolling work
end mousedown

(Not having tried the above, I can't guarantee it will work.  But I
think something very like it will.)

James C. Beard  (beard@wuibc2.wustl.edu)

taylorj@yvax.byu.edu (06/26/89)

I agree with the other guys that it would probably be more efficient to
dispense with the button, but here's a quick and easy way to find out if the
user has scrolled the field.  When you put up the button, save the scroll state
of the field in a global variable ('put the scroll of field <whatever> into
oldScroll').  The put a mouseWithin handler in the field that checks to see
if the scroll has changed.  It would look something like this:

  on mouseWithin
    global oldScroll
    if the scroll of me <> oldScroll then
      -- user has scrolled: hide button, or whatever you need to do
    end if
  end mouseWithin


Jim Taylor
Microcomputer Support for Curriculum
Brigham Young University
taylorj@byuvax.bitnet