Page 1 of 1
Button Icons...
Posted: Sun Nov 25, 2012 9:47 pm
by mbond52
HI,
When I assign a .png or .jpg (that I have imported into the stack as a Control) as a as the Icon of a button (the size of the graphic being exactly the same as the button) and set the Label as centred, the Icon shifts up and the Label text drops down. If the Label text is left or right aligned then the image fits perfectly and the text is centred vertically. I have tried playing with all of the properties of the button but can't find how to stop this from happening. Can anyone help?
Thanks - Martin
Re: Button Icons...
Posted: Sun Nov 25, 2012 9:55 pm
by sturgis
Probably the easiest way around this is to not show the name of the button, and use a separate label field for your text. That way you can size and position it as you wish without dealing with the issue you discovered.
Re: Button Icons...
Posted: Sun Nov 25, 2012 10:12 pm
by mbond52
Hi Sturgis,
Thanks for the rapid response.
I did consider your idea but then I would have to mess about with a script for that separate Label so that the Hover and Hilighted Icons of the button change as if the cursor was visiting the Button directly. In the past I have put the required Label in the Icon graphic, but for this app I plan to dynamically create a number of buttons based on a DB look up and assign their Label as part of the create command. I would have thought that what I am after is a basic function and that I am missing something fairly fundamental.
Many Thanks - Martin
Re: Button Icons...
Posted: Sun Nov 25, 2012 11:02 pm
by sturgis
Have been messing with buttons and labels for a bit here. First thing is, you can mess with the margin settings and force the label to where you want it to be (height of the button / 2 - the textsize of the button / 2 gets you close)
But for me, having the "show name" property of the button turned on changes the view of the image. (part of it leaves the button) There is just strangeness involved in how this works.
So an alternative might be to set this up as a custom control. (a group) one way might be to have an image object at the lowest layer of the group, label next, and a transparent button over the top. Group them together, then add a script to the group that changes the image object based on mouseEnter, mouseLeave. Since a transparent button still shows the mousedown/mouseup color adjustment you can see a click, you can change the image on mouseenter and mouse leave. Since the button is transparent you can see the label fine, and position it by:
set the width of field "whateverlabel" to the width of img "whateverimage"
set the loc of field "whateverlabel" to the loc of img "whateverimage"
Of course having set the label to center justify.
If you don't like the way the blending of the transparent button and the image work together you can mess with the blend types and probably find a better look for what you want to accomplish. I had good luck just now using srcXor as the blend method.
I'm sure there are other ways to accomplish this, but maybe this will work. (oh, any time you are changing the screen, lock screen, do whatever, unlock screen)
If all your buttons will be the same size, after you group your first sample and get it working (I recommend setting the group margins to 0 also) you can hide it somewhere and the clone or copy it, set its properties as needed and you're good to go.
Re: Button Icons...
Posted: Mon Nov 26, 2012 12:40 am
by mbond52
Once again, thank you Sturgis.
That may well be the route I will have to go. Thanks for the guidance on this. However, I cant help thinking that Runrev should have resolved what appears to be a basic issue. I can see that this problem was there in V4.6.4 and today I upgraded to V5.5.3 and it is still there. It would save a lot of working around if this was made to work correctly,
Thank - Martin
Re: Button Icons...
Posted: Tue Nov 27, 2012 2:13 am
by bn
Hi,
I agree that
It would save a lot of working around if this was made to work correctly,
It is a mess.
But here is what you never wanted to know about labels on buttons with icons.
Maybe Sturgis will appreciate this madness
The stack has the code to center them.
Kind regards
Bernd
Re: Button Icons...
Posted: Tue Nov 27, 2012 3:04 am
by sturgis
I appreciate all kinds of madness. Thx!
EDIT: Very cool stack! But man if there was a better way it would be.. er.. better.
Re: Button Icons...
Posted: Tue Nov 27, 2012 11:16 am
by Klaus
Hi all,
I already filed a bug report/feature request for this (text on top of icon in buttons) in early 2009, but it is still undconfirmed...
Best
Klaus
Re: Button Icons...
Posted: Tue Nov 27, 2012 9:13 pm
by mbond52
Hi Bernd,
Wow, that is brilliant. Thank you very much for that. It has saved me a lot of time and needless extra coding. I will store it away safely for future use as well.
Many Thanks - Martin