Page 1 of 1
Change button background on mouse click
Posted: Wed Feb 26, 2014 11:12 pm
by croivo
Let's say my button has background image [picture1] and what I want to do is when I click on that button, the background image changes from [picture1] to [picture2]. How to change image background? The code should be something like:
Code: Select all
set the backgroundimage of me to [ImageName]
Regards,
croivo
Re: Change button background on mouse click
Posted: Wed Feb 26, 2014 11:19 pm
by FourthWorld
If you use the button's icon properties this becomes very easy with automatic behavior - check out the Dictionary filtered for "icon" to see all the icon options available.
Re: Change button background on mouse click
Posted: Wed Feb 26, 2014 11:35 pm
by croivo
FourthWorld wrote:If you use the button's icon properties this becomes very easy with automatic behavior - check out the Dictionary filtered for "icon" to see all the icon options available.
Thanks

Here is my code now (if somebody wants to know):
Re: Change button background on mouse click
Posted: Sat Apr 12, 2014 7:28 pm
by croivo
Hello guys, I have question about how to change the background of text field when it is selected (active). I want to have, for example, green text fied but when user click with mouse on it (or with TAB key navigates to that field), it become blue. And when user click on some other field or on empty area, the background changes back to green.
Any ideas?
Re: Change button background on mouse click
Posted: Sat Apr 12, 2014 7:48 pm
by FourthWorld
While only buttons have an icon property, all controls in LiveCode have many other properties to govern appearance, including foregroundColor, backgroundColor, foregroundPattern, and backgroundPattern.
The latter is what you're looking for here:
set the backgroundPattern of field "SomeField" to tSomeImageID
Re: Change button background on mouse click
Posted: Sat Apr 12, 2014 7:56 pm
by croivo
FourthWorld wrote:While only buttons have an icon property, all controls in LiveCode have many other properties to govern appearance, including foregroundColor, backgroundColor, foregroundPattern, and backgroundPattern.
The latter is what you're looking for here:
set the backgroundPattern of field "SomeField" to tSomeImageID
I know for that, my problem is that I don't know what code to put instead of "on mouseUp" (i don't know how that line of code i called). How to know when text field is selected (active)?
Re: Change button background on mouse click
Posted: Sat Apr 12, 2014 8:03 pm
by jacque
See the "focusIn" and "focusOut" entries in the dictionary. Or, depending on what your script does, you might use "openfield" and "closefield" and "exitField" instead.
Edit: I see that your field is editable. In that case use the open/close/exit field messages. Focus messages only work in locked fields.
Re: Change button background on mouse click
Posted: Sat Apr 12, 2014 11:39 pm
by croivo
jacque wrote:See the "focusIn" and "focusOut" entries in the dictionary. Or, depending on what your script does, you might use "openfield" and "closefield" and "exitField" instead.
Edit: I see that your field is editable. In that case use the open/close/exit field messages. Focus messages only work in locked fields.
That is exactly what I wanted. Thanks!