How to center a control?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to center a control?
Hi,
I'm just getting started and think I'm progressing fairly well, but I cannot find out how to center a control on a card.
Thanks in advance.
I'm just getting started and think I'm progressing fairly well, but I cannot find out how to center a control on a card.
Thanks in advance.
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Re: How to center a control?
peaslee...
Well, let's say you want to place a button at the centre of a card...
Have a read of the dictionary... look at 'Location'
be well
Dixie
Well, let's say you want to place a button at the centre of a card...
Code: Select all
set the loc of button 1 to the loc of this card
be well
Dixie
Re: How to center a control?
Is this the peaslee that I know from elsewhere?
-Doc-
-Doc-
Re: How to center a control?
Could there be more than one?doc wrote:Is this the peaslee that I know from elsewhere?
-Doc-
Bruce
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Re: How to center a control?
Dixie,
Sorry I wasn't clear enough. There are ways in the IDE to align controls against each other. What I want to do is center a control or group of controls vertically and/or horizontally without computing the location.
Sorry I wasn't clear enough. There are ways in the IDE to align controls against each other. What I want to do is center a control or group of controls vertically and/or horizontally without computing the location.
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Re: How to center a control?
Hi peaslee,
Look at the menu "Object", "Aligne Selected Control"
Best
Jean-Marc
Look at the menu "Object", "Aligne Selected Control"
Best
Jean-Marc
https://alternatic.ch
Re: How to center a control?
Well, I didn't think so, but ya never now these days...Could there be more than one?
Bruce

Don't know how far or deep you've gotten involved in LiveCode yet Bruce, but if you wait out the "what is crazy stuff all about" syndrome, you'll love it!
I've been an "official user" for about six years now and almost exclusively for the last three or so. There aren't many languages out there that I haven't tried at one time or the other and absolutely NOTHING holds a candle to the productivity I've found using LiveCode. It's opened up a whole range of projects for me that I would have been hesitant to even attempt in years past... These days, If I can envision it, I just dive right in and go at it.

Good to see ya here sir, and hope you have fun with it!
-Doc-
Re: How to center a control?
Are you asking about spacing/distributing a group of selected controls equally maybe?
If that's the case, you can access the "align objects" menu from the properties palette once you have more than one control selected.

-Doc-
If that's the case, you can access the "align objects" menu from the properties palette once you have more than one control selected.

-Doc-
Re: How to center a control?
Peaslee...
I hope that I have now understood what you want
Have a look at the attached stack
be well
Dixie
PS.... now having seen Doc's reply, I obviously didn't understand
I hope that I have now understood what you want

Have a look at the attached stack
be well
Dixie
PS.... now having seen Doc's reply, I obviously didn't understand

- Attachments
-
- buttonAlign.rev.zip
- (1.41 KiB) Downloaded 331 times
Re: How to center a control?
We're getting closer. I want to center a control horizontally. This dialog editor is from a different system. With Button 1 highlighted, clicking on the button at the end of the arrow centers Button 1 horizontally in the dialog. (Sorry for the size of the arrow.) Can I do the same here or do I have to compute its location?
- Attachments
-
- Center.jpg (40.79 KiB) Viewed 10942 times
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Re: How to center a control?
You can easily determine the new location of the button by taking the 'x' part of the location of the card and the 'y' part of the location of the button. Here's some example code:
HTH,
Jan Schenkel.
Code: Select all
on mouseUp
local tNewLocation
put item 1 of the location of this card & \
comma & item 2 of the location of me \
into tNewLocation
set the location of me to tNewLocation
end mouseUp
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: How to center a control?
I found a way to trick the IDE. If you have three buttons, you can align them across the card with the Inspector, and the middle on gets centered. So I add a button on either side, center them, then delete the extra two.
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Re: How to center a control?
Hi Bruce,
you can also use "the loc" of the current card as a reference!
To center an object horizontally AND vertically:
...
set the loc of btn x to the loc of this cd
...
Only horizontally:
...
put item 1 of the loc of this cd into tX
put item 2 of the loc of btn X into tY
set the loc of btn x to tX,tY
...
Only vertically:
...
put item 1 of the loc of btn X into tX
put item 2 of the loc of this cd into tY
set the loc of btn X to tX,tY
...
You get the picture.
Best
Klaus
you can also use "the loc" of the current card as a reference!
To center an object horizontally AND vertically:
...
set the loc of btn x to the loc of this cd
...
Only horizontally:
...
put item 1 of the loc of this cd into tX
put item 2 of the loc of btn X into tY
set the loc of btn x to tX,tY
...
Only vertically:
...
put item 1 of the loc of btn X into tX
put item 2 of the loc of this cd into tY
set the loc of btn X to tX,tY
...
You get the picture.
Best
Klaus
Re: How to center a control?
Klaus
It took me about twenty minutes with graph paper and the Dictionary to see why that works, but it was good for my education.
Thanks,
Bruce
It took me about twenty minutes with graph paper and the Dictionary to see why that works, but it was good for my education.
Thanks,
Bruce
Bruce Peaslee
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM
Windows 7 Home Premium (Service Pack 1)
ACPI x-64 based PC 9GB RAM