Fields resize

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
laurpapo
Posts: 38
Joined: Thu Jun 21, 2012 4:25 pm

Fields resize

Post by laurpapo » Mon Sep 03, 2012 3:56 pm

We have a program for creating concept maps, and a feature that allows the positions of all of the fields to be recorded in a text file. When we want to 'open' that same map, it just calls on the text file and recreates the fields in the positions they were in when the map was saved, and inputs the text that was in each field into the new node. So it is basically a save/open text file.

I have it set to record the size of each field when saved, and set the new node to that size when opened. However, for some reason it doesn't like putting the text on just one line, even if it saved that way. So if it saved with "transformation processes" on one line in the field, when we open it again the size of the field is the same, but "processes" gets bumped down a line and, consequently, cut off. Any ideas on how to fix this? I will include the script for when files are opened, and the script for the templatefield.

this is only a small part of the openmap handler, but it is the only relevant part, I think:

Code: Select all

       --adjusts the size of the new node to fit content
         set the height of last field to item 6 of line x of gFinalMapData
         set the width of last field to item 7 of line x of gFinalMapData 
         --puts the content of the node into the new node
         put item 5 of line x of gFinalMapData into last field
templatefield script:

Code: Select all

on keydown --checks when the key is pressed
   if gEditMode is true then
      updateSize
      pass keydown
   else
      pass keydown
      
   end if
end keydown

on backspaceKey
   updatesize
   pass backspaceKey
end backspaceKey

on updatesize
   if gEditMode is true then
      if the formattedwidth of me + 1 >100 then
         set the dontwrap of me to false
         set the height of me to the formattedheight of me + 1
      else  
         set the dontwrap of me to true
         set the width of me to the formattedwidth of me + 1
      end if
      set the height of me to the formattedheight of me + 1
   end if
end updatesize

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10323
Joined: Wed May 06, 2009 2:28 pm

Re: Fields resize

Post by dunbarx » Mon Sep 03, 2012 4:11 pm

Hi.

Is the "dontWrap" preserved when you recreate the new field? You can use "the properties", er, property, to restore the field to its most recent state. Save these in a custom property somewhere, and they will all be reconstituted later.

But why not just hide the fields of interest instead of recreating them? Then all properties would be maintained, and the text would not need to be restored.

Craig Newman

laurpapo
Posts: 38
Joined: Thu Jun 21, 2012 4:25 pm

Re: Fields resize

Post by laurpapo » Mon Sep 03, 2012 4:24 pm

I am pretty sure the properties stay the same, because when the field is recreated it is created from the same templatefield as the original was. And the maps are saved so that multiple maps can be reopened on the same card at later times. This is for a psychology experiment. Simply hiding the fields would not allow us to do what we want to do with the program.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10323
Joined: Wed May 06, 2009 2:28 pm

Re: Fields resize

Post by dunbarx » Mon Sep 03, 2012 5:14 pm

Well, does changing, by hand, the "dontwrap" of the newly created field to "true" place the text the way you want it? I see you were fooling around with this property in one of your routines.

Craig Newman

laurpapo
Posts: 38
Joined: Thu Jun 21, 2012 4:25 pm

Re: Fields resize

Post by laurpapo » Mon Sep 03, 2012 5:38 pm

Sorry to be a bother--I figured it out. The updatesize handler that adjusted the dontwrap property was only called BEFORE the new text was put into the fields, when it should have been after. Silly me. Thanks for all of the help!

Post Reply