Zeev Goldstein Well-Known Member Licensed User Longtime User Jan 17, 2023 #1 Hi, Is there a way to get button's color (background & textcolor) in runtime? (The button is a simple B4A button - dim b as button) Thanks
Hi, Is there a way to get button's color (background & textcolor) in runtime? (The button is a simple B4A button - dim b as button) Thanks
Solution aeric Jan 18, 2023 Zeev Goldstein said: hi i need to GET the color not to SET it so your solution did not do it... Click to expand... Just reverse the code. B4X: Copy Dim ButtonColor As Int = b.As(B4XView).Color Log(ButtonColor)
Zeev Goldstein said: hi i need to GET the color not to SET it so your solution did not do it... Click to expand... Just reverse the code. B4X: Copy Dim ButtonColor As Int = b.As(B4XView).Color Log(ButtonColor)
klaus Expert Licensed User Longtime User Jan 17, 2023 #2 Declare it as a B4XView then you can set the color with: Button1.Color = Colors.White or, if you want a border and corner radii. Button1.SetColorAndBorder(Colors.White, 1dip, Colors.Black, 10dip) And to get the color with: BackColor = Button1.Color Upvote 0
Declare it as a B4XView then you can set the color with: Button1.Color = Colors.White or, if you want a border and corner radii. Button1.SetColorAndBorder(Colors.White, 1dip, Colors.Black, 10dip) And to get the color with: BackColor = Button1.Color
V vatedome04 New Member Jan 17, 2023 #3 klaus said: Declare it as a B4XView then you can set the color with: Button1.Color = Colors.White or, if you want a border and corner radii. Button1.SetColorAndBorder(Colors.White, 1dip, Colors.Black, 10dip) And to get the color with: BackColor = Button1.Color Click to expand... thank you for sharing i got same problem Upvote 0
klaus said: Declare it as a B4XView then you can set the color with: Button1.Color = Colors.White or, if you want a border and corner radii. Button1.SetColorAndBorder(Colors.White, 1dip, Colors.Black, 10dip) And to get the color with: BackColor = Button1.Color Click to expand... thank you for sharing i got same problem
Zeev Goldstein Well-Known Member Licensed User Longtime User Jan 17, 2023 #4 klaus said: Declare it as a B4XView then you can set the color with: Button1.Color = Colors.White or, if you want a border and corner radii. Button1.SetColorAndBorder(Colors.White, 1dip, Colors.Black, 10dip) And to get the color with: BackColor = Button1.Color Click to expand... Thanks, As said it's a simple button (old app) so I can't go now and change it all... So your solution as good as it is is not applicable for my app So, is there a way to get the colors of a simple button that was declared dim b as button? Thanks Upvote 0
klaus said: Declare it as a B4XView then you can set the color with: Button1.Color = Colors.White or, if you want a border and corner radii. Button1.SetColorAndBorder(Colors.White, 1dip, Colors.Black, 10dip) And to get the color with: BackColor = Button1.Color Click to expand... Thanks, As said it's a simple button (old app) so I can't go now and change it all... So your solution as good as it is is not applicable for my app So, is there a way to get the colors of a simple button that was declared dim b as button? Thanks
aeric Expert Licensed User Longtime User Jan 17, 2023 #5 Then cast it to B4XView. B4X: Copy b.As(B4XView).Color = xui.Color_Green Upvote 0
Zeev Goldstein Well-Known Member Licensed User Longtime User Jan 17, 2023 #6 aeric said: Then cast it to B4XView. B4X: Copy b.As(B4XView).Color = xui.Color_Green Click to expand... Wow, that's interesting I will try it and revert of course Thanks Upvote 0
aeric said: Then cast it to B4XView. B4X: Copy b.As(B4XView).Color = xui.Color_Green Click to expand... Wow, that's interesting I will try it and revert of course Thanks
Zeev Goldstein Well-Known Member Licensed User Longtime User Jan 18, 2023 #7 aeric said: Then cast it to B4XView. B4X: Copy b.As(B4XView).Color = xui.Color_Green Click to expand... hi i need to GET the color not to SET it so your solution did not do it... Upvote 0
aeric said: Then cast it to B4XView. B4X: Copy b.As(B4XView).Color = xui.Color_Green Click to expand... hi i need to GET the color not to SET it so your solution did not do it...
aeric Expert Licensed User Longtime User Jan 18, 2023 #8 Zeev Goldstein said: hi i need to GET the color not to SET it so your solution did not do it... Click to expand... Just reverse the code. B4X: Copy Dim ButtonColor As Int = b.As(B4XView).Color Log(ButtonColor) Upvote 0 Solution
Zeev Goldstein said: hi i need to GET the color not to SET it so your solution did not do it... Click to expand... Just reverse the code. B4X: Copy Dim ButtonColor As Int = b.As(B4XView).Color Log(ButtonColor)
Zeev Goldstein Well-Known Member Licensed User Longtime User Jan 18, 2023 #9 aeric said: Just reverse the code. View attachment 138222 B4X: Copy Dim ButtonColor As Int = b.As(B4XView).Color Log(ButtonColor) Click to expand... thanks will try Upvote 0
aeric said: Just reverse the code. View attachment 138222 B4X: Copy Dim ButtonColor As Int = b.As(B4XView).Color Log(ButtonColor) Click to expand... thanks will try
Zeev Goldstein Well-Known Member Licensed User Longtime User Jan 19, 2023 #10 that worked like charm - exactly what i needed - thank you! Upvote 0