Fields, Margins, Tab on Return

Ken Ray kray at sonsothunder.com
Thu Aug 19 02:26:57 EDT 2004


On 8/19/04 12:44 AM, "SimPLsol at aol.com" <SimPLsol at aol.com> wrote:

>      Create a new rectangular field with four lines of 9 pt. type on 12 pt.
> leading - 48 pixels tall. Default margins are 5.
> 1. Try to set the margins to zero. Half of the leading on the top line
> disappears. Width margins seem to be tied to height margins, which makes no
> sense to 
> me. I can find no way to set either set of margins to zero. Is there a way?

Yes, but it's not "zero" - for some reason, if you want to set it to
*appear* to be 0, you set it to 2,2,0,0 (if you are not showing a border),
or 2,4,0,0 (if you are showing a border).

Remember that you can use a single number for margins (in which case it
applies to all sides), or a 4 item string for left,top,right,bottom margins.

> 2. Type something in the first line of this field. Hit the return key three
> times; the cursor is flashing on line four; all is well. Hit the return key
> again; the field scrolls; the cursor is on line five; the info on line one is
> invisible; and the only way to get back to seeing line one is to delete lines
> (there is, of course, no scroll bar on a rectangle field)! Rectangle fields
> should not scroll! Right? I don't want the user to put a five line address in
> a 
> four line address field.

I don't think it's a bug (as I have used this approach to "scroll" movie
titles), but you can prevent it this way:

on returnInField
  if the number of lines of me is 4 then
    beep
    exit returnInField
  else
    pass returnInField
  end if
end returnInField

If you want something more flexible based on the current field height:

on returnInField
  put round(the height of me / the textHeight of me) into tMaxLines
  if the number of lines of me is tMaxLines then
    beep
    exit returnInField
  else
    pass returnInField
  end if
end returnInField

Now keep in mind that you'd want to trap enter key as well as people pasting
in data, but this'll get you started.

> What I want is a std., non-scrolling, rectangle field, with 3D, a one pixel
> border, the ability to type into all lines, the height of the field to be 12
> times the number of lines in the field, and (on some fields) the ability to
> auto 
> tab without losing the last line of the field. Is there a simple way to do
> this?

To do the "autotab" you can amend my script above as follows:

on returnInField
  put round(the height of me / the textHeight of me) into tMaxLines
  if the number of lines of me is tMaxLines then
    type tab
    exit returnInField
  else
    pass returnInField
  end if
end returnInField

HTH,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list