Page 1 of 1
icongravity and labelgravity
Posted: Tue Aug 11, 2015 4:44 pm
by makeshyft
Hi Livecode,
For some inexplicable reason, it seems reasonable that a button's label goes over it;s icon. if the icon's gravity is set to left and the label justification is set to left. the same goes for right justified and right gravity settings. For static text, font, icon, sure one can set it to look right, but beyond that, this functionality just doesn't make sense. This is especailly true with dynamic buttons who's label changes, and when the user is allowed to change the font of the label.
Wouldn't it make more sense if the label snapped to the edge of the icon so that it didn't cover it?????
So here is my suggestion for a "labelgravity" property that allows the label to snap to the edge of the icon.
This way we don't have to build our own controls that follow this simple idea of not covering the icon with the label.
Thank you for taking this into consideration.
Re: icongravity and labelgravity
Posted: Tue Aug 11, 2015 6:46 pm
by dunbarx
Hi.
I see the icon covering the label, not the other way around. Is that what you meant? I don't know if there is a "right" way for this, that is, which of the two ought to be on top, but the property I would think you would want is something that could switch that order, sort of a localized "layer" property.
Craig Newman
Re: icongravity and labelgravity
Posted: Tue Aug 11, 2015 7:17 pm
by Randy Hengst
FWIW, I agree with the idea of “labelGravity” being aware of the icon setting. The only way I’ve accomplished the look you described is to set icongravity to left, then set the textalign to right or center and adjust the font size and button width. Before iconGravity was introduced that align trick was only good with radio and checkbox buttons.
Re: icongravity and labelgravity
Posted: Thu Aug 13, 2015 5:24 pm
by makeshyft
For me, let label covers the icon.... see attached image.
I just want to be able to left align icon, left align label.
My app is able to be translated using a database of strings, so when the string size changes (of the label) ..... it throws off the appearance of the button and depending on the size of the label, it can end up covering the icon.
just saying the label should be aware of the icon and its position and should be positioned next to it, not overtop.
Re: icongravity and labelgravity
Posted: Thu Aug 13, 2015 5:34 pm
by makeshyft
Randy Hengst wrote:FWIW, I agree with the idea of “labelGravity” being aware of the icon setting. The only way I’ve accomplished the look you described is to set icongravity to left, then set the textalign to right or center and adjust the font size and button width. Before iconGravity was introduced that align trick was only good with radio and checkbox buttons.
Yep...thats the way to do it, except when the text is dynamic, it makes life really difficult.

..but if the button itself just snapped the label to the edge of the icon, problem solved.
Re: icongravity and labelgravity
Posted: Thu Aug 13, 2015 7:45 pm
by bn
Hi Tom,
could you try this script in an extra button and let it run against a button of yours with icon and label and labelGravity to left, textAlign to right?
For me as soon as you have 5 or more characters in the label it adjusts the label to the right of the icon by changing the button width.
Code: Select all
on mouseUp
-- fill in name of your btn
put "b1" into tBtnName
ask "text for label of btn"
if it is "" then exit mouseUp
lock screen
set the label of btn tBtnName to it
put the formattedWidth of btn tBtnName into tFW
put the formattedWidth image id (the icon of btn tBtnName) into tIW
put the topLeft of btn tBtnName into tTL
put the rightmargin of btn tBtnName into tMarg
set the width of btn tBtnName to tFW + tIW + tMarg
set the topLeft of btn tBtnName to tTL
unlock screen
end mouseUp
is it this what you mean?
Kind regards
Bernd
Re: icongravity and labelgravity
Posted: Thu Aug 13, 2015 8:45 pm
by bn
Hi all,
I goofed up on the first version of the script I posted above by trying to make it more generic. Forgot to clean it up enough.
I corrected the script and it should now work when you fill in the name of your button to fill the variable tBtnName
Sorry for any inconvenience.
Kind regards
Bernd
Re: icongravity and labelgravity (solved?)
Posted: Mon Aug 24, 2015 2:57 am
by makeshyft
Hi Bernd,
Sorry I have not checked this thread, and didn't get any notifications.... thanks for your efforts in writing the code. I solved the problem by creating my own reusable button object, and so I pretty much did what you did but in a different way. I hope it comes in handy for someone.
Thanks everyone who weighed in.