|
Post by click22 on Dec 15, 2019 15:45:31 GMT
Can the background colour of a button be changed?
eg Define a button colour as yellow, left click once to change it to green, click again to return to yellow
|
|
|
Post by Rod on Dec 15, 2019 16:36:26 GMT
You could show and hide predefined buttons of the correct color. But you need to be able to react to different button presses. So if it is red you have a red handler if it is green you have a green handler. Will try some code later on if no one jumps in.
|
|
|
Post by click22 on Dec 15, 2019 16:50:28 GMT
Great idea Rod, but how do I define the background colour of the two alternative buttons? I can change the colour of the label, but changing the background would be more easily seen.
|
|
|
Post by cundo on Dec 15, 2019 17:51:18 GMT
Hi, what about using a BMPBUTTON?
|
|
|
Post by Rod on Dec 15, 2019 18:31:20 GMT
yeah, background requires bmpbutton. it can be as photorealistic as you like.
|
|
|
Post by tsh73 on Dec 15, 2019 21:19:43 GMT
I had a drawn button routine for a while. Just tried changing color, try clicking last button - works nicely for me. Tips and Utilities\ Drawn button
|
|
|
Post by honkytonk on Dec 16, 2019 13:32:56 GMT
NOMAINWIN WindowWidth = 600: WindowHeight = 400 UpperLeftX = 200: UpperLeftY = 20 GRAPHICBOX #w.m 5, 5, 585, 360 OPEN "button" FOR window_nf AS #w #w, "TRAPCLOSE [closebutt]" #w.m, "when leftButtonDown [scanne]" #w.m "down;fill darkgreen" #w.m, "color yellow;backcolor darkgreen" #w.m, "place 75 65": #w.m, "\ <-- Button" #w.m "color yellow;backcolor yellow" #w.m, "place 20 50": #w.m, "boxfilled 70 75" #w.m "color red;backcolor yellow" #w.m, "place 30 65": #w.m, "\ Clic"
wait [scanne] flag=flag+1 if flag=2 then flag=0 xb=MouseX: yb=MouseY if xb > 20 and xb < 70 and yb > 50 and yb < 75 then if flag= 1 then #w.m, "color red;backcolor red" #w.m, "place 20 50": #w.m, "boxfilled 70 75" #w.m "color yellow;backcolor red" #w.m, "place 30 65": #w.m, "\ Clic" end if if flag= 0 then #w.m, "color yellow;backcolor yellow" #w.m, "place 20 50": #w.m, "boxfilled 70 75" #w.m "color red;backcolor yellow" #w.m, "place 30 65": #w.m, "\ Clic" end if end if
wait [closebutt] CLOSE #w END
|
|
|
Post by click22 on Dec 18, 2019 17:27:02 GMT
Many thanks for all your suggestions. As soon as I have tried them out and understand how they work I will let you know which one I favour for my needs.
|
|
|
Post by click22 on Jan 1, 2020 18:08:06 GMT
Thanks honkytonk, I can see how your solution works now. JB help uses commands 'print #w.m, ...' but your code omits 'print'. I'm obviously missing something. Can you overlay graphic Box elements eg a rectangle on top of a table?
|
|
|
Post by honkytonk on Jan 2, 2020 8:32:14 GMT
Thanks honkytonk, I can see how your solution works now. JB help uses commands 'print #w.m, ...' but your code omits 'print'. I'm obviously missing something. Can you overlay graphic Box elements eg a rectangle on top of a table? The "print" before the # is optional, as well as the ";" at the end of the instructions. You can make a simple box black (not filled) around the pseudo button to improve the visual. ....."place 75 65": #w.m, "\ <-- Button" #w.m "color black;size 4" #w.m, "place 18 48": #w.m, "box 73 78"
#w.m "color yellow;backco..... We can superimpose bmp, but the big ones will hide the small ones, of course.
|
|