Page 1 of 1

Trying to get id of label field?

Posted: Tue Jun 25, 2013 2:30 pm
by jalz
Hi Guys,

I've created a couple of icons using the label control. I basically dragged the label control, made sure it was opaque, filled the background in to a specific colour, changed text colour and line spacing so the 'icon' looked exactly the way I wanted it. I then duplicated that control, changed the background colour slightly, as I wanted to use it as a hover over on a button.

The problem is trying to attach those two controls to my button. I've inserted a blank button, but I can't change the icons for hover over etc to the ones from the label field as they don't have ID numbers on them. Is there anyway I can get the id numbers of the static controls I have created?

Many thanks
jalz

Re: Trying to get id of label field?

Posted: Tue Jun 25, 2013 2:35 pm
by Klaus
Hi jalz,

let me see if I really get it... 8-)

1. You created some FIELDS (labels are fields) and modified them until they look OK for you.
2. You want to use them (the way they look) as ICONS in buttons.
Is that correct so far?

Well, you cannot do this directly, since ICONS in buttons need to be IMAGES!
You could "import snapshot..." to create IMAGES from your different fields
and use them in your buttons.


Best

Klaus

Re: Trying to get id of label field?

Posted: Tue Jun 25, 2013 3:24 pm
by jalz
Thanks Klaus,

I think I will recreate them as images and import them. Thought there might be a way of converting the label field into an image/icon/sprite directly from within livecode.

Re: Trying to get id of label field?

Posted: Tue Jun 25, 2013 3:34 pm
by Klaus
Hi jalz,
jalz wrote:Thanks Klaus,

I think I will recreate them as images and import them. Thought there might be a way of converting the label field into an image/icon/sprite directly from within livecode.
yes, you can "import snapshot..." in Livecode to "turn" your fields into images!
No other way, sorry.


Best

Klaus

Re: Trying to get id of label field?

Posted: Tue Jun 25, 2013 6:07 pm
by dave_probertGA6e24
Jalz,

Just to be clear - the "import snapshot ..." is a Livecode programming code statement (look it up in the Livecode Dictionary).

Klaus doesn't mean that you can only create snapshot images Outside of Livecode and Import them (even though the command sounds like that!) Although creating the images outside of Livecode is perfectly acceptable as well. :)

Hope that helps,
Dave

Re: Trying to get id of label field?

Posted: Tue Jun 25, 2013 7:50 pm
by mwieder
There's another way out of this as well:

Set the script of the hover label to

Code: Select all

on mouseLeave
  lock screen
  hide me
  show field "NormalButton"
  unlock screen
end mouseLeave

on mouseUp
  -- do your normal mouseUp stuff here in the hover button
end mouseUp
Set the script of the normal label to

Code: Select all

on mouseEnter
  lock screen
  hide me
  show field "HoverButton"
  unlock screen
end mouseEnter
Set the loc of both labels to the same thing
Hide the hover label

Now when you move the cursor of the displayed label the hover label will appear and when you move the mouse off it the normal label will appear. No button needed.