• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Button alternate colors

Explorer ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

Hi, I need help making my button field alternate between yellow and red when it's clicked. TIA

TOPICS
How to

Views

789

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jun 16, 2021 Jun 16, 2021

As 'Mouse UP' event of button field add this:
event.target.fillColor = (color.equal(color.yellow, event.target.fillColor)) ? color.red : color.yellow;

Votes

Translate

Translate
Community Expert , Jun 17, 2021 Jun 17, 2021

Sure, you can use this:
if(event.value > 255)
event.value = 255;
var a = event.value;
var b = 255-a;
event.target.fillColor = ["RGB",a/255,a/255,a/255];
event.target.textColor = ["RGB",b/255,b/255,b/255];

Votes

Translate

Translate
Community Expert ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

As 'Mouse UP' event of button field add this:
event.target.fillColor = (color.equal(color.yellow, event.target.fillColor)) ? color.red : color.yellow;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Hi, Nesa i need help again.
I have text field which i want to set fill and text colors to be RGB color opposites ( if value is 0 fill is black and text is white)
depending on field value,and if field value is higher then 255 it should be 255.Can you help pls?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

LATEST

Sure, you can use this:
if(event.value > 255)
event.value = 255;
var a = event.value;
var b = 255-a;
event.target.fillColor = ["RGB",a/255,a/255,a/255];
event.target.textColor = ["RGB",b/255,b/255,b/255];

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines