align objects in IDE aligning to wrong object?

Geoff Canyon gcanyon at gmail.com
Sun Jan 5 00:23:55 EST 2014


On Sat, Jan 4, 2014 at 6:27 PM, Dr. Hawkins <dochawk at gmail.com> wrote:
  On Sat, Jan 4, 2014 at 3:10 PM, Geoff Canyon <gcanyon at gmail.com> wrote:

  > 6.5.1 on Mavericks, and I couldn't replicate this.

  That's what I'm using, and it came and went.

  Happened enough times that I could be certain I was selecting by click,
and
  then by shift-click.


I tried using the properties palette and the menu commands, and selecting
with clicks and then by dragging a selection rectangle.

There's not much going on in the palette script:

on mouseUp
  revSaveLayout
  put the selectedObjects into tObjectNames
  put the number of lines in tObjectNames into tNumberOfObjects
  if tNumberOfObjects < 2 then exit to top
  get line 1 of tObjectNames
  put the left of it into tXcoord
  repeat with i = 1 to tNumberOfObjects
    get line i of tObjectNames
    set the left of it to tXcoord
    send "revCacheGeometry true" to it
  end repeat
end mouseUp

If there's a bug, maybe it's in revSaveLayout. I'd change the above to:

on mouseUp
   put the selectedObjects into tObjectNames
   put the left of (line 1 of tObjectNames) into tLeft
   delete line 1 of tObjectNames
   revSaveLayout
   repeat for each line L in tObjectNames
      set the left of L to tLeft
      send "revCacheGeometry true" to L
   end repeat
end mouseUp

Or better still (I just did this) group the four buttons top, left, bottom,
and right, and then empty their scripts and set the script of the group to:

on mouseUp
   put the selectedObjects into tObjectNames
   put the short name of the target into P
   do "put the" && P && "of" && (line 1 of tObjectNames) && "into tProp"
   delete line 1 of tObjectNames
   revSaveLayout
   lock screen
   repeat for each line L in tObjectNames
      set the P of L to tProp
      send "revCacheGeometry true" to L
   end repeat
   unlock screen
end mouseUp


Does anyone know a way to avoid the "do" statement in the above? Variables
will evaluate to the underlying property in a set statement, but not a put
(as far as I know). In any case the above saves code and avoids redundancy.
Performance is still poor with large numbers of objects because of the call
to revCacheGeometry -- does anyone know if that actually needs to be called
for each object, or just once at the end? This is crazy fast by comparison
for greater than a few hundred controls:

on mouseUp
   put the selectedObjects into tObjectNames
   put the short name of the target into P
   do "put the" && P && "of" && (line 1 of tObjectNames) && "into tProp"
   delete line 1 of tObjectNames
   revSaveLayout
   lock screen
   repeat for each line L in tObjectNames
      set the P of L to tProp
      --send "revCacheGeometry true" to L
   end repeat
   send "revCacheGeometry true" to (line 1 of tObjectNames)
   unlock screen
end mouseUp



More information about the use-livecode mailing list