Using a group's handles to resize controls within group
Posted: Sun Oct 20, 2013 11:07 pm
Hello,
I have made a searchable text field control that I want to be able to drag out of a palette and place on a stack (like a normal textField, but with additional functionality). Before I can do this, I need to allow the control to be resized by the user (so once they drag it out, they can make it fit in their stack). The drag handles that appear when in edit mode are for the group, but I get some really strange behavior when I try to set the text field width and height in a resizeControl handler within the group script. Has anyone successfully done this?
You can setup the following simplified test to demonstrate the problem I am having:
1. Create a button "theButton" and a field "theField"
2. Group them and name the group "theGroup"
3. While in edit mode, grab the right-edge handle and increase the width of the group. Notice the default behavior is to increase the width of the group in the direction you are dragging.
4. Grab the bottom-edge handle and increase the height of the group. The default behavior is to increase the height of the group in the direction you are dragging.
5. Within the group script, place the following code:
6. Drag the right edge handle to increase the width of the group just like step 3. This time, I expected the SAME behavior, but with the width of the field also increasing in the direction of the dragging. Instead, the group and the field increase in size, but the left edge isn't fixed like before.
7. Drag the bottom edge handle to increase the height of the group. Instead of increasing the height of just the group, the width of the group (and the text field) increases. This is really odd to me, because the width of the group shouldn't be increasing when the bottom-edge handle is dragged.
The only thing I can surmise is that the size of the group rect is updated by the engine when you change the dimensions of the controls within the group. But since I am then setting the dimensions of the controls within the group based off of the groups dimensions, things are getting confused.
Well, I'm at least confused!
Thanks,
Tom
I have made a searchable text field control that I want to be able to drag out of a palette and place on a stack (like a normal textField, but with additional functionality). Before I can do this, I need to allow the control to be resized by the user (so once they drag it out, they can make it fit in their stack). The drag handles that appear when in edit mode are for the group, but I get some really strange behavior when I try to set the text field width and height in a resizeControl handler within the group script. Has anyone successfully done this?
You can setup the following simplified test to demonstrate the problem I am having:
1. Create a button "theButton" and a field "theField"
2. Group them and name the group "theGroup"
3. While in edit mode, grab the right-edge handle and increase the width of the group. Notice the default behavior is to increase the width of the group in the direction you are dragging.
4. Grab the bottom-edge handle and increase the height of the group. The default behavior is to increase the height of the group in the direction you are dragging.
5. Within the group script, place the following code:
Code: Select all
on resizeControl
set the width of field "theField" to (the width of me)
pass resizeControl
end resizeControl
7. Drag the bottom edge handle to increase the height of the group. Instead of increasing the height of just the group, the width of the group (and the text field) increases. This is really odd to me, because the width of the group shouldn't be increasing when the bottom-edge handle is dragged.
The only thing I can surmise is that the size of the group rect is updated by the engine when you change the dimensions of the controls within the group. But since I am then setting the dimensions of the controls within the group based off of the groups dimensions, things are getting confused.
Well, I'm at least confused!
Thanks,
Tom