Hi guys. Is there a way to bypass Locking? In Xcode locking can be top and bottom vs Xojo forced side locking.
How can I lock my TextArea or any other objects to top and bottom only? Is this possible with code?

c.LockLeft = false
c.LockRight = false

you can turn it off always.
Then left and right are on your own.

1 Like

RectControls in desktop have 4 boolean lock properties, one for each side, which you can set however you want.

The default is for right and top to be true and the others false.


1 Like

Thanks… I inserted the below but it is still locking to the left. The top and bottom are fine tho :slight_smile:

EditingField.LockRight = False
EditingField.LockLeft = False
EditingField.LockTop = True
EditingField.LockBottom = True

Im kinda half-way there. Still one side is locking when using “False”

What are you expecting to happen if all are turned off?

1 Like

I’m trying to achieve: only top and bottom locked (similar to how it is done using xcode)

OK, but if left isnt locked, what do you imagine will happen to the left position if the parent is resized?

The only effect ‘left locked = false’ has, is to allow a control to move right IF and only if right locked = true

We do that, and then assign left in Resize event of Window to keep control centered.

I believe it should be more simpler to allow more free locking like (top and bottom only) for apps with left and right panels and a center view. I’m working around possibilities of building an app for students like myself with a text area at the center with left and right controls. The TextArea I’d prefer to stay in position (top and bottom), similar to MS Word and Apple Pages. Not every app idea should be forced to lock to either left or right.

It’s kinda restricting, unless there’s a way and I’m doing it wrong.

It seems to me that the issue may be the order in which you are doing it. Have you tried locking the ones you want first and then unlocking the ones you don’t.

Yes, thanks. I placed the top and bottom in 1st and 2nd but it is still locked to the left

Leave it locked left and in the Resizing event, do this:

TextArea1.Left = (Self.Width - TextArea1.Width) / 2

My bad, I missed the top/bottom only request. The suggestion from Christian and Greg are the way to go. It seems you are looking for a grid-based layout.

1 Like

Thank you very much… Just have to find the right width since “2” is too small :slight_smile:

2 isn’t the width. You’re dividing the remaining space in half so the control appears centered on the window.

1 Like

Oh, Thanks again. I got it done as wanted.