Allowing user to change size and location of a field

dunbarx at aol.com dunbarx at aol.com
Wed Mar 7 16:35:48 EST 2012


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

 



More information about the use-livecode mailing list