Allowing user to change size and location of a field

Ralph DiMola rdimola at evergreeninfo.net
Wed Mar 7 17:06:00 EST 2012


I was generating a file of InDesign Tags for a publishing project. The
request was for me to break lines and pages manually because of some crazy
header and footer requirements not handled by the $2,000 InDesign SW. I used
the formattedwidth on a dummy fields to determine where the line breaks
should be. After I realized that the font point size of an LC field is not a
physical point size (72 per inch) but pixels AND the 12 point type in
InDesign was actually 65 "point" in LC at my PC resolution on my monitor, I
successfully fit the most number of words on a line and broke the line lines
very accurately. To LC's credit a non-breaking space (ASCII 160) does not
constitute a LC word break. This allowed me to keep say the city, state and
zip code on a single line as requested. Formattedwidth for proportional
fonts was very accurate and worked out for me.


Ralph DiMola
IT Director
Evergreen Information Services
rdimola at evergreeninfo.net

-----Original Message-----
From: use-livecode-bounces at lists.runrev.com
[mailto:use-livecode-bounces at lists.runrev.com] On Behalf Of dunbarx at aol.com
Sent: Wednesday, March 07, 2012 4:36 PM
To: use-livecode at lists.runrev.com
Subject: Re: Allowing user to change size and location of a field

Your second one is a poser.  The formatted widths and heights do not help, I
think, if you do not already have the field populated with text. You are
asking for the "potentialFormattedWidth", essentially.


Without using a monospaced font like courier, I would not know how to begin.
If you did use such a font, though, you could calculate the number of chars
and lines that would fit, based on the rect of the field. I made a field in
courier 12. I know how many chars per pixel width I can fit, and how many
lines I can fit as well. A simple function will give the number of chars for
any field size. Once you have that, you can trap keydown to limit the total
char count.


But someone smarter will have to answer for dynamically spaced fonts. Maybe
this is a start?


Craig Newman



-----Original Message-----
From: Glen Bojsza <gbojsza at gmail.com>
To: How to use LiveCode <use-livecode at lists.runrev.com>
Sent: Wed, Mar 7, 2012 11:35 am
Subject: Allowing user to change size and location of a field


Hello,

I would like to allow a user to be able to change the size and location of
a text field in an application.

The following allows the user to select the field via right-shift click and
then with the pointer tool move the field to where they want and resize the
field.

With the next right-shift click the field is deselected and the browse tool
is shown.

Problem is the user cannot put text into the field anymore?

Am I approaching this correctly?

on mouseDown theButton
   if theButton is 3 AND the shiftkey is down then
      get the selected of me
      switch it
         case  "true"
            set the selected of me to false
            set the tool to browse
            select empty
            break
         case  "false"
            set the selected of me to true
            set the tool to pointer
            break
      end switch
   else
      pass mouseDown
      end if
end mouseDown

Another question which may not be able to be answered is... can you limit
the number of characters in the field based on the new size the user has
made?

thanks,

Glen
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription

preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

 
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list