Resizing a Text Field Dynamically, While Locking XY Position

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
rontoledo
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 11
Joined: Fri Jan 09, 2009 6:51 am

Resizing a Text Field Dynamically, While Locking XY Position

Post by rontoledo » Tue Jan 13, 2009 9:58 pm

Hello All,

I'm new to Revolution, and am attempting to create a paned interface.

Specifically, I have two text fields, with a little grabber icon between them. The effect I'm trying to accomplish is that, as I drag the little grabber button between the two fields, the two fields on either side are to automatically resize in width.

I'm experimenting with just the left text field and grabber icon at this time. My current challenge is that when I drag the grabber left and right, the text field on the left does resize in width-- however, it resizes from its centerpoint outwards. Ideally, I would want the text field's XY coordinates to remain locked, while only the _right_ side of the text field grows outward or inward.

Is there a property for Rev objects that can configure objects to resize from one specific side?

Thank you,
Ron Toledo

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Tue Jan 13, 2009 10:11 pm

Hi ron,

you could try something like this:

in your grabber thingy:

Code: Select all

on mouseDown
  set the uAllowDrag of me to true
end mouseDown

on mouseUp
  set the uAllowDrag of me to false
end mouseUp

on mouseRelease
  set the uAllowDrag of me to false
end mouseRelease

on mouseMove x,y
  if not the uAllowDrag of me then exit mouseMove
  set the loc of me to x,item 2 of the loc of me
  set the rect of fld "leftField" to the topLeft of fld "leftField",the left of me,the bottom of fld "leftField"
  set the rect of fld "rightField" to the right of me,the top of fld "rightField,the botRight of fld "rightField"
end mouseMove
This is out of the top of my head, so there may be typos, but you get the idea.

Hope that helps,

malte

rontoledo
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 11
Joined: Fri Jan 09, 2009 6:51 am

Post by rontoledo » Tue Jan 13, 2009 10:22 pm

Malte,

Thank you much for this; I'm going to give a whirl shortly. It's ironic that you would reply-- I've been experimenting with AnimationEngine's excellent constraintLinear and constraintLinearCallback functions to achieve the left/right slider effect for the grabber!

Everything has been working swimmingly, save for the text field resize, which you've pointed me in the right direction for.

Will let you know how it goes.

Thank you again,
Ron

rontoledo
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 11
Joined: Fri Jan 09, 2009 6:51 am

Post by rontoledo » Tue Jan 13, 2009 10:59 pm

Hello again,

Just gave it a try, and it worked perfectly!

As I'm using AnimationEngine for the grabber (so that it constrains to moving along the X axis only (with an invisible line graphic as the grabber's guide/contraint), I only modified the grabber's handler as follows:

Code: Select all

on ConstrainLinearCallback
    set the rectangle of field "leftField" to the topLeft of field "leftField", the left of me, the bottom of field "leftField"
    set the rectangle of field "rightField" to the right of me, the top of field "rightField", the botRight of field "rightField"
end ConstrainLinearCallback
Amazing how elegant Revolution is; imagine attempting to purely code the same functionality in, say, Adobe Flex. Yikes.

Btw, when I think of Adobe Air, and the amount of code it takes to build Flash-based desktop applications, and compare it to accomplishing the same thing in Revolution, I'm amazed by the potential amount of time saved by leveraging the latter.

Thank you much,
Ron

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Tue Jan 13, 2009 11:46 pm

Hey Ron,

glad it helped!

This is a nice example of using AE. :) Happy to see the lib being useful to you.

Cheers,

malte

Post Reply