
Button properties - ColorOverlay
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Button properties - ColorOverlay
Can some please explain the use of a buttons "Graphic Effects" property. I understand how to use it through the inspector during design time but not while the program is running via code. What I don't understand or follow in the Dictionary explaination, is how to set those properties during a runtime mode. For example. Say when a person clicked Button100, i want to change the "Graphic Effects" of that button by changing the ColorOverlay property. Can I set the color I want for the overlay during design time and then enable the Color Overlay property in runtime via code? Do I need to set the color also in runtime before enabling the ColorOverlay property of that button? How do I set the ColorOverlay property of Button100 to "true"? If so, not sure how to. Thanks in advance. 

Re: Button properties - ColorOverlay
mackus,
to read out the coloroverlay property of a button use this:
change the coloroverlay of a button (if you do it on the first one created it will be button 1, else name it and adapt the script, same for a field you make. In another button you put
the coloroverlay is an array, above code reads the array out and converts it into a readable form. The same for the other graphic effects: you could say the dropshadow of an object
To set the coloroverlay of a button by script you would say
If you play around with the graphic effects and read them out with the first script you get a feeling for the parameters you want.
This is the same, btw, for gradients.
Dont let the arrays scare you off, just use above syntax and you can set these properties easily from a script.
regards
Bernd
to read out the coloroverlay property of a button use this:
change the coloroverlay of a button (if you do it on the first one created it will be button 1, else name it and adapt the script, same for a field you make. In another button you put
Code: Select all
on mouseUp
put the coloroverlay of btn 1 into tOverlayArray
combine tOverlayArray using return and comma
put tOverlayArray into field 1
end mouseUp
Code: Select all
on mouseUp
put the dropshadow of btn 1 into tAnyyArrayName
combine tAnyyArrayName using return and comma
put tAnyyArrayName into field 1
end mouseUp
Code: Select all
on mouseUp
put "normal" into tArray["blendmode"]
put "255,255,0" into tArray["color"]
put "100" into tArray["opacity"]
set the colorOverlay of btn 1 to tArray
end mouseUp
This is the same, btw, for gradients.
Dont let the arrays scare you off, just use above syntax and you can set these properties easily from a script.
regards
Bernd
Re: Button properties - ColorOverlay
thx BN for the response. I will experiment.
Re: Button properties - ColorOverlay
BN, one more question... I hope...
is there a default value for a standard button just created? Example, if i copy your code, create a default button and field, run the program, the output into field window is null.
only after i change one of the properties of the ColorOverlay, will the field items (blendmode, color and opacity) show up with their values. So i was wondering, if i had a default button with no ColorOverlay props, then changed those props in code and then wanted to change the button back to what it looked like at the creation time, what would i set the values back to? I tried creating a tResetArray and loaded the blendmode, color and opacity with "" with no luck. I also created an Array tResetArray2 with no structure and tried to set the coloroverlay of my button to it, hoping it would reset back to normal. So it made me wonder what is normal? How would you reset to design time defaults in runtime, after change props in runtime??
thanks again
mackus
is there a default value for a standard button just created? Example, if i copy your code, create a default button and field, run the program, the output into field window is null.
only after i change one of the properties of the ColorOverlay, will the field items (blendmode, color and opacity) show up with their values. So i was wondering, if i had a default button with no ColorOverlay props, then changed those props in code and then wanted to change the button back to what it looked like at the creation time, what would i set the values back to? I tried creating a tResetArray and loaded the blendmode, color and opacity with "" with no luck. I also created an Array tResetArray2 with no structure and tried to set the coloroverlay of my button to it, hoping it would reset back to normal. So it made me wonder what is normal? How would you reset to design time defaults in runtime, after change props in runtime??
thanks again
mackus
Re: Button properties - ColorOverlay
To reset to the default look, you can set the colorOverlay to empty
Code: Select all
set the colorOverlay of btn 1 to empty
Re: Button properties - ColorOverlay
sturgis,
thx but I must be doing something wrong.
code below
on mouseUp
put "normal" into tArray["blendmode"]
put "255,255,0" into tArray["color"]
put "100" into tArray["opacity"]
set the colorOverlay of btn 1 to tArray
wait 2 sec
-- CODE causes REV to crash
--put empty into tArray
--set the colorOverlay of btn 1 to tArray
--CODE doesnt change btn back to default condition
set the colorOverlay of btn 1 to empty
end mouseUp
The first commented out section causes REV to completely crash and the second commented section, doesnt change back to default conditions.
What am i doing wrong?
thx
mackus
thx but I must be doing something wrong.
code below
on mouseUp
put "normal" into tArray["blendmode"]
put "255,255,0" into tArray["color"]
put "100" into tArray["opacity"]
set the colorOverlay of btn 1 to tArray
wait 2 sec
-- CODE causes REV to crash
--put empty into tArray
--set the colorOverlay of btn 1 to tArray
--CODE doesnt change btn back to default condition
set the colorOverlay of btn 1 to empty
end mouseUp
The first commented out section causes REV to completely crash and the second commented section, doesnt change back to default conditions.
What am i doing wrong?
thx
mackus
Re: Button properties - ColorOverlay
To see it work, try putting the following code in a button.
This way, when the mouse is over the button it should set the overlay, when you move off the button it should reset to a standard old button.
As for why its not working in your tests, not sure without seeing more of your code. Hopefully someone will be able to point you to the reason.
Code: Select all
on mouseEnter
put "normal" into tArray["blendmode"]
put "255,255,0" into tArray["color"]
put "100" into tArray["opacity"]
set the colorOverlay of me to tArray
end mouseEnter
on mouseLeave
set the colorOverlay of me to empty
end mouseLeave
As for why its not working in your tests, not sure without seeing more of your code. Hopefully someone will be able to point you to the reason.
Re: Button properties - ColorOverlay
thx sturgis,
Strange. You code provides the effect i want, but i dont want it to happen for 2 seconds, so on mouseleave wouldnt work for me. But it is strange why it wont work in my code as i listed above. Pretty straight forward. Must be something to do with the Wait command, taking the focus off the btn and then when time is up, doesnt know how to apply the empty array to the colorOverlay.
Strange. You code provides the effect i want, but i dont want it to happen for 2 seconds, so on mouseleave wouldnt work for me. But it is strange why it wont work in my code as i listed above. Pretty straight forward. Must be something to do with the Wait command, taking the focus off the btn and then when time is up, doesnt know how to apply the empty array to the colorOverlay.

Re: Button properties - ColorOverlay
quick code if someone can figure out what i am doing wrong.
1 button
1 field
it appears that the color change visually does not happen before the repeat loop, but only after the loop is done
on mouseUp
put "normal" into tArray["blendmode"]
put "255,255,0" into tArray["color"]
put "100" into tArray["opacity"]
set the colorOverlay of btn 1 to tArray
--button should change to yellow at this point
repeat with x=1 to 10000000
-- waist time loop
end repeat
--button should go back to default colors at this point
set the colorOverlay of btn 1 to empty
--show process complete
put "done" into field 1
end mouseUp
1 button
1 field
it appears that the color change visually does not happen before the repeat loop, but only after the loop is done
on mouseUp
put "normal" into tArray["blendmode"]
put "255,255,0" into tArray["color"]
put "100" into tArray["opacity"]
set the colorOverlay of btn 1 to tArray
--button should change to yellow at this point
repeat with x=1 to 10000000
-- waist time loop
end repeat
--button should go back to default colors at this point
set the colorOverlay of btn 1 to empty
--show process complete
put "done" into field 1
end mouseUp
Re: Button properties - ColorOverlay
Mackus
I did not get your code to work either, although I added a wait with messages, strange. Anyway this works and at the same time it introduces the send in time construct which is very versatile and uselful. Instead of a repeat loop to waist time or a wait for x seconds in a handler it is more efficient to use send in time.
regards
Bernd
I did not get your code to work either, although I added a wait with messages, strange. Anyway this works and at the same time it introduces the send in time construct which is very versatile and uselful. Instead of a repeat loop to waist time or a wait for x seconds in a handler it is more efficient to use send in time.
Code: Select all
on mouseUp
put "normal" into tArray["blendmode"]
put "255,255,0" into tArray["color"]
put "100" into tArray["opacity"]
set the colorOverlay of btn 1 to tArray
--button should change to yellow at this point
-- will change colorOverlay
send NoColorOverlay to me in 200 milliseconds
end mouseUp
on NoColorOverlay
set the colorOverlay of btn 1 to empty
end NoColorOverlay
Bernd
Re: Button properties - ColorOverlay
Hi mackus,
I found that while you can change the colorOverlay properties repeatedly in the mouseUp handler, it seems you can only set them to empty with a separate handler. The following script changes the color property continually during the repeat, resets with ResetColorOverlay, then continues by waiting for 2 seconds before outputting “done” in the message box. This requires one button and one field:
...I’m testing in RevMedia 4.0.0-dp-3, and can’t find any reference to colorOverlay in my dictionary or User Guide, or in the properties of the button, so I might be missing something, but still the above script works. I wonder if property inheritance has something to do with it?
[I see Bernd has also found the separate handler solution. Cheers!]
Regards,
Michael
I found that while you can change the colorOverlay properties repeatedly in the mouseUp handler, it seems you can only set them to empty with a separate handler. The following script changes the color property continually during the repeat, resets with ResetColorOverlay, then continues by waiting for 2 seconds before outputting “done” in the message box. This requires one button and one field:
Code: Select all
on mouseUp
put "normal" into tArray["blendmode"]
put "255,255,0" into tArray["color"]
put "100" into tArray["opacity"]
set the colorOverlay of btn 1 to tArray
put 1 into fld 1
repeat with x=1 to 10000
-- tArray["color"] cycles through values of x
put x&",255,0" into tArray["color"]
set the colorOverlay of btn 1 to tArray
put fld 1 + 1 into fld 1
end repeat
--button goes back to original settings at this point
ResetColorOverlay
-- mouseUp continues with wait
wait 2 seconds with messages
--show process complete
put "done"
end mouseUp
on ResetColorOverlay
set the colorOverlay of btn 1 to empty
end ResetColorOverlay
[I see Bernd has also found the separate handler solution. Cheers!]
Regards,
Michael
Re: Button properties - ColorOverlay
Hi Regulae,
I had to add a "wait 0 milliseconds with messages" in the repeat loop to let Rev display the color changes.
regards
Bernd
I had to add a "wait 0 milliseconds with messages" in the repeat loop to let Rev display the color changes.
Code: Select all
on mouseUp
put "normal" into tArray["blendmode"]
put "255,255,0" into tArray["color"]
put "100" into tArray["opacity"]
set the colorOverlay of btn 1 to tArray
put 1 into fld 1
repeat with x=1 to 255
-- tArray["color"] cycles through values of x
put x&",255,0" into tArray["color"]
-- alternatively you could write
-- put x,255,0 into tArray["color"]
set the colorOverlay of btn 1 to tArray
put fld 1 + 1 into fld 1
-- let Rev display the color change
wait 0 millisecond with messages
end repeat
--button goes back to original settings at this point
ResetColorOverlay
-- mouseUp continues with wait
wait 2 seconds with messages
--show process complete
put "done"
end mouseUp
on ResetColorOverlay
set the colorOverlay of btn 1 to empty
end ResetColorOverlay
Bernd
Re: Button properties - ColorOverlay
Hi mackus,
put this into the script of any button, field or image and watch. It is just to show how you can use the gradient/graphic effects. In this case to make a bad user interface.
regards
Bernd
put this into the script of any button, field or image and watch. It is just to show how you can use the gradient/graphic effects. In this case to make a bad user interface.

Code: Select all
local sTrack, x1, y1, sDropArray
on mouseEnter
put the loc of me into tCenterLoc
put item 1 of tCenterLoc into x1
put item 2 of tCenterLoc into y1
put the mouseLoc into tNewCoordinates
put item 1 of tNewCoordinates into x2; put item 2 of tNewCoordinates into y2
put x1-x2 into oppositeLeg; put y1-y2 into adjacentLeg
-- 0 at right horizontally, counterclockwise, 90 at top
put round (abs(atan2(adjacentLeg,oppositeleg)*180/pi-180)) into tMouseAngle
put the dropshadow of me into sDropArray
put tMouseAngle into sDropArray["angle"]
put 30 into sDropArray["distance"]
set the dropshadow of me to sDropArray
put true into sTrack
send "trackTheMouse" to me in 1 milliseconds
end mouseEnter
on mouseLeave
set the dropShadow of me to ""
put false into sTrack
put false into tShape
end mouseLeave
on trackTheMouse
if sTrack then
put the mouseLoc into tNewCoordinates
put item 1 of tNewCoordinates into x2; put item 2 of tNewCoordinates into y2
put x1-x2 into oppositeLeg; put y1-y2 into adjacentLeg
-- tAbsAngle is the angle in mathematical angles i.e.
-- right horizontal is 0 degree, progressing counter clockwise to 360
put round (abs(atan2(adjacentLeg,oppositeleg)*180/pi-180)) into tAbsAngle
put the dropshadow of me into sDropArray
-- the angle
put tAbsAngle into sDropArray["angle"]
-- the color
repeat 3
put random(255) & "," after tColor
end repeat
delete last char of tColor -- a comma
put tColor into sDropArray["color"]
lock screen
set the dropshadow of me to sDropArray
unlock screen
if "trackTheMouse" is not in the pendingMessages then
send "TrackTheMouse" to me in 30 milliseconds
end if
end if
end trackTheMouse
Bernd
Re: Button properties - ColorOverlay
Greetings Bernd,
I’ve checked again, and the colour change is seen without the “wait” with messages on my setup. I’m using RevMedia 4.0.0-dp-3 running under Windows XP- perhaps there is a subtle difference due to how Rev runs on different OS’s? Actually, I was half expecting to need something to “unblock” the repeat, and was a little surprised it worked without it. Perhaps there are messages involved in changing the properties involved in colorOverlay which have to get through. I’ve just intalled a newer version of RevMedia, which fully supports colorOverlay and dropShadow, just so I could try your script. Very nice indeed!
Regards,
Michael
I’ve checked again, and the colour change is seen without the “wait” with messages on my setup. I’m using RevMedia 4.0.0-dp-3 running under Windows XP- perhaps there is a subtle difference due to how Rev runs on different OS’s? Actually, I was half expecting to need something to “unblock” the repeat, and was a little surprised it worked without it. Perhaps there are messages involved in changing the properties involved in colorOverlay which have to get through. I’ve just intalled a newer version of RevMedia, which fully supports colorOverlay and dropShadow, just so I could try your script. Very nice indeed!
Regards,
Michael
Re: Button properties - ColorOverlay
Thanks All... Great Forum... Problem Solved
I look forward to helping others as I get a better handle on Rev.
Cheers
Mackus
I look forward to helping others as I get a better handle on Rev.

Cheers
Mackus