Hello Friends,
Welcome back with another post on PowerApps. Today, we will learn about Color-Picker feature. Surprised, as there is no such built-in feature in PowerApps. Right, therefore, we will build the logic here. I am going to create a very basic component. It will include Text Inputs as well as Sliders for RGBA. User can type-in the RGBA color values in text input boxes or it can use sliders as well. Instant changes to the color will reflect in the output box. So, let's begin.
- Login to PowerApps Maker Portal. Create a new app and provide as suitable name.
- Click on Components and then click on "+ New component". It will add a new component. So, we got our component platform, where we will develop out Color-Picker component.
- Give component a suitable name. I am using "SJColorPicker'.
- Set the size of component as-
- Width: 250
- Height: 140
- Add a rectangle to give your component a border.
- Name: CP_rct_Border
- X: 0
- Y: 0
- Width: SJColorPicker.Width
- Height: SJColorPicker.Height
- Fill: Color.Transparent
- BorderColor: Color.Black
- BorderSyle: BorderStyle.Solid
- BorderThickness: 1
- Add a TextInput control for Red Color.
- Name: CP_txt_RedColor
- Default: "127"
- Format: Number
- Size: Self.Height*35%
- Align: Align.Center
- LineHeight: 1
- X: CP_rct_Border.X+CP_rct_Border.BorderThickness
- Y: CP_rct_Border.Y+CP_rct_Border.BorderThickness
- Width: (SJColorPicker.Width-2*CP_rct_Border.BorderThickness)/5
- Height: (SJColorPicker.Height-2*CP_rct_Border.BorderThickness)/5
- PaddingTop: 5
- PaddingBottom: Self.PaddingTop
- PaddingLeft: Self.PaddingTop
- PaddingRight: Self.PaddingTop
- Color: RGBA(0, 0, 0, 1)
- Fill: RGBA(255, 255, 255, 1)
- BorderColor: Color.Black
- BorderSyle: BorderStyle.Solid
- BorderThickness: 1
- RadiusTopLeft: 0
- RadiusTopRight: Self.RadiusTopLeft
- RadiusBottomLeft: Self.RadiusTopLeft
- RadiusBottomRight: Self.RadiusTopLeft
- DisabledBorderColor: Self.BorderColor
- DisabledColor: Self.Color
- DisabledFill: Self.Fill
- HoverBorderColor: Self.BorderColor
- HoverColor: Self.Color
- HoverFill: Self.Fill
- PressedBorderColor: Self.BorderColor
- PressedColor: Self.Color
- PressedFill: Self.Fill
- Now, add a TextInput control for Green Color.
- Name: CP_txt_GreenColor
- Default: "127"
- Format: Number
- Size: Self.Height*35%
- Align: Align.Center
- LineHeight: 1
- X: CP_txt_RedColor.X+CP_txt_RedColor.Width
- Y: CP_rct_Border.Y+CP_rct_Border.BorderThickness
- Width: (SJColorPicker.Width-2*CP_rct_Border.BorderThickness)/5
- Height: (SJColorPicker.Height-2*CP_rct_Border.BorderThickness)/5
- PaddingTop: 5
- PaddingBottom: Self.PaddingTop
- PaddingLeft: Self.PaddingTop
- PaddingRight: Self.PaddingTop
- Color: RGBA(0, 0, 0, 1)
- Fill: RGBA(255, 255, 255, 1)
- BorderColor: Color.Black
- BorderSyle: BorderStyle.Solid
- BorderThickness: 1
- RadiusTopLeft: 0
- RadiusTopRight: Self.RadiusTopLeft
- RadiusBottomLeft: Self.RadiusTopLeft
- RadiusBottomRight: Self.RadiusTopLeft
- DisabledBorderColor: Self.BorderColor
- DisabledColor: Self.Color
- DisabledFill: Self.Fill
- HoverBorderColor: Self.BorderColor
- HoverColor: Self.Color
- HoverFill: Self.Fill
- PressedBorderColor: Self.BorderColor
- PressedColor: Self.Color
- PressedFill: Self.Fill
- Now, add a TextInput control for Blue Color.
- Name: CP_txt_BlueColor
- Default: "127"
- Format: Number
- Size: Self.Height*35%
- Align: Align.Center
- LineHeight: 1
- X: CP_txt_GreenColor.X+CP_txt_GreenColor.Width
- Y: CP_rct_Border.Y+CP_rct_Border.BorderThickness
- Width: (SJColorPicker.Width-2*CP_rct_Border.BorderThickness)/5
- Height: (SJColorPicker.Height-2*CP_rct_Border.BorderThickness)/5
- PaddingTop: 5
- PaddingBottom: Self.PaddingTop
- PaddingLeft: Self.PaddingTop
- PaddingRight: Self.PaddingTop
- Color: RGBA(0, 0, 0, 1)
- Fill: RGBA(255, 255, 255, 1)
- BorderColor: Color.Black
- BorderSyle: BorderStyle.Solid
- BorderThickness: 1
- RadiusTopLeft: 0
- RadiusTopRight: Self.RadiusTopLeft
- RadiusBottomLeft: Self.RadiusTopLeft
- RadiusBottomRight: Self.RadiusTopLeft
- DisabledBorderColor: Self.BorderColor
- DisabledColor: Self.Color
- DisabledFill: Self.Fill
- HoverBorderColor: Self.BorderColor
- HoverColor: Self.Color
- HoverFill: Self.Fill
- PressedBorderColor: Self.BorderColor
- PressedColor: Self.Color
- PressedFill: Self.Fill
- Now, add a TextInput control for Alpha. Alpha value is used for transparency. 0 means transparent while 100% means opaque.
- Name: CP_txt_Alpha
- Default: "50"
- Format: Number
- Size: Self.Height*35%
- Align: Align.Center
- LineHeight: 1
- X: CP_txt_BlueColor.X+CP_txt_BlueColor.Width
- Y: CP_rct_Border.Y+CP_rct_Border.BorderThickness
- Width: (SJColorPicker.Width-2*CP_rct_Border.BorderThickness)/5
- Height: (SJColorPicker.Height-2*CP_rct_Border.BorderThickness)/5
- PaddingTop: 5
- PaddingBottom: Self.PaddingTop
- PaddingLeft: Self.PaddingTop
- PaddingRight: Self.PaddingTop
- Color: RGBA(0, 0, 0, 1)
- Fill: RGBA(255, 255, 255, 1)
- BorderColor: Color.Black
- BorderSyle: BorderStyle.Solid
- BorderThickness: 1
- RadiusTopLeft: 0
- RadiusTopRight: Self.RadiusTopLeft
- RadiusBottomLeft: Self.RadiusTopLeft
- RadiusBottomRight: Self.RadiusTopLeft
- DisabledBorderColor: Self.BorderColor
- DisabledColor: Self.Color
- DisabledFill: Self.Fill
- HoverBorderColor: Self.BorderColor
- HoverColor: Self.Color
- HoverFill: Self.Fill
- PressedBorderColor: Self.BorderColor
- PressedColor: Self.Color
- PressedFill: Self.Fill
- Now, add a TextInput control for Output color. This text box will be used to show the result color based upon the RGBA selected.
- Name: CP_txt_ResultColor
- Default: ""
- Format: Text
- Size: Self.Height*35%
- Align: Align.Center
- LineHeight: 1
- DisplayMode: DisplayMode.Disabled
- X: CP_txt_Alpha.X+CP_txt_Alpha.Width
- Y: CP_rct_Border.Y+CP_rct_Border.BorderThickness
- Width: (SJColorPicker.Width-2*CP_rct_Border.BorderThickness)/5
- Height: (SJColorPicker.Height-2*CP_rct_Border.BorderThickness)/5
- PaddingTop: 5
- PaddingBottom: Self.PaddingTop
- PaddingLeft: Self.PaddingTop
- PaddingRight: Self.PaddingTop
- Color: RGBA(0, 0, 0, 1)
- Fill: RGBA(255, 255, 255, 1)
- BorderColor: Color.Black
- BorderSyle: BorderStyle.Solid
- BorderThickness: 1
- RadiusTopLeft: 0
- RadiusTopRight: Self.RadiusTopLeft
- RadiusBottomLeft: Self.RadiusTopLeft
- RadiusBottomRight: Self.RadiusTopLeft
- DisabledBorderColor: Self.BorderColor
- DisabledColor: Self.Color
- DisabledFill: Self.Fill
- HoverBorderColor: Self.BorderColor
- HoverColor: Self.Color
- HoverFill: Self.Fill
- PressedBorderColor: Self.BorderColor
- PressedColor: Self.Color
- PressedFill: Self.Fill
- One part is completed. However, a couple of properties yet to set but we will do it later. Now, we will add 4 Slider controls.
- Add, a slider control for Red color.
- Name: CP_sld_RedColor
- Default: If(IsBlank(vrSelectedRedColorValue),127,vrSelectedRedColorValue)
- Max: 255
- Min: 0
- ShowValue: false
- HandleSize: Self.Height*60%
- X: CP_txt_RedColor.X
- Y: CP_txt_RedColor.Y+CP_txt_RedColor.Height
- Width: SJColorPicker.Width-2*CP_rct_Border.BorderThickness
- Height: CP_txt_RedColor.Height
- ValueFill: RGBA(255, 0, 0, 1)
- Add, a slider control for Green color.
- Name: CP_sld_GreenColor
- Default: If(IsBlank(vrSelectedGreenColorValue),127,vrSelectedGreenColorValue)
- Max: 255
- Min: 0
- ShowValue: false
- HandleSize: Self.Height*60%
- X: CP_txt_RedColor.X
- Y: CP_sld_RedColor.Y+CP_sld_RedColor.Height
- Width: SJColorPicker.Width-2*CP_rct_Border.BorderThickness
- Height: CP_txt_RedColor.Height
- ValueFill: RGBA(0, 255, 0, 1)
- Add, a slider control for Blue color.
- Name: CP_sld_BlueColor
- Default: If(IsBlank(vrSelectedBlueColorValue),127,vrSelectedBlueColorValue)
- Max: 255
- Min: 0
- ShowValue: false
- HandleSize: Self.Height*60%
- X: CP_txt_RedColor.X
- Y: CP_sld_GreenColor.Y+CP_sld_GreenColor.Height
- Width: SJColorPicker.Width-2*CP_rct_Border.BorderThickness
- Height: CP_txt_RedColor.Height
- ValueFill: RGBA(0, 0, 255, 1)
- Add, a slider control for Alpha.
- Name: CP_sld_Alpha
- Default: If(IsBlank(vrSelectedAlphaValue),50,vrSelectedAlphaValue)
- Max: 100
- Min: 0
- ShowValue: false
- HandleSize: Self.Height*60%
- X: CP_txt_RedColor.X
- Y: CP_sld_BlueColor.Y+CP_sld_BlueColor.Height
- Width: SJColorPicker.Width-2*CP_rct_Border.BorderThickness
- Height: CP_txt_RedColor.Height
- ValueFill: RGBA(0, 0, 0, 1)
- Basic setup has been done. Now the functional part is remaining. First define two properties of the component by selecting the component and then clicking on the "+ New custom property".
- Add an Input Property-
- Display Name: Decimal-Hex Table
- Name: DecimalHexTable
- Property type: Input
- Data type: Table
- Click on Save. Now click on this property to set it's default value.
- Replace the current display table with below one-
Table( { Decimal: 0, Hex: "0" }, { Decimal: 1, Hex: "1" }, { Decimal: 2, Hex: "2" }, { Decimal: 3, Hex: "3" }, { Decimal: 4, Hex: "4" }, { Decimal: 5, Hex: "5" }, { Decimal: 6, Hex: "6" }, { Decimal: 7, Hex: "7" }, { Decimal: 8, Hex: "8" }, { Decimal: 9, Hex: "9" }, { Decimal: 10, Hex: "A" }, { Decimal: 11, Hex: "B" }, { Decimal: 12, Hex: "C" }, { Decimal: 13, Hex: "D" }, { Decimal: 14, Hex: "E" }, { Decimal: 15, Hex: "F" } )
- This table will be used to convert Decimal value to Hex and vice-versa.
- Add another custom property. This time it would type of Output.
- Display Name: Output Color
- Name: OutputColor
- Property type: Output
- Data type: Color
- Click on Save. Now click on this property to set it's default value. Change the default value to "vrOutputColor".
- Now we will start applying functionality for "OnChange" event of each control.
- Click on CP_sld_Alpha and choose OnChange property. Update the function as-
Set( vrSelectedAlphaValue, Self.Value ); Set( vrOutputColor, ColorValue( Concatenate( "#", Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_RedColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_RedColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_GreenColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_GreenColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_BlueColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_BlueColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_Alpha.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_Alpha.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ) ) ) ) );
- Click on CP_sld_BlueColor and choose OnChange property. Update the function as-
Set( vrSelectedBlueColorValue, Self.Value ); Set( vrOutputColor, ColorValue( Concatenate( "#", Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_RedColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_RedColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_GreenColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_GreenColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_BlueColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_BlueColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_Alpha.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_RedColor.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ) ) ) ) );
- Click on CP_sld_GreenColor and choose OnChange property. Update the function as-
Set( vrSelectedGreenColorValue, Self.Value ); Set( vrOutputColor, ColorValue( Concatenate( "#", Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_RedColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_RedColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_GreenColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_GreenColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_BlueColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_BlueColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_Alpha.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_RedColor.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ) ) ) ) );
- Click on CP_sld_RedColor and choose OnChange property. Update the function as-
Set( vrSelectedRedColorValue, Self.Value ); Set( vrOutputColor, ColorValue( Concatenate( "#", Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_RedColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_RedColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_GreenColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_GreenColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_BlueColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_BlueColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_Alpha.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_RedColor.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ) ) ) ) );
- Now, we will update the "Default", "HintText", "OnChange" properties of the text boxes.
- Click the CP_txt_RedColor control and select Default property of textbox. Update the function as below-
If(IsBlank(vrSelectedRedColorValue),CP_sld_RedColor.Value,vrSelectedRedColorValue)
- Update the same for "HintText" property as well.
- Update the "OnChange" property as-
Set( vrSelectedRedColorValue, Value(Self.Text) ); Set( vrOutputColor, ColorValue( Concatenate( "#", Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_RedColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_RedColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_GreenColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_GreenColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_BlueColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_BlueColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_Alpha.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_RedColor.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ) ) ) ) );
- Click the CP_txt_GreenColor control and select Default property of textbox. Update the function as below-
If(IsBlank(vrSelectedGreenColorValue),CP_sld_GreenColor.Value,vrSelectedGreenColorValue)
- Update the same for "HintText" property as well.
- Update the "OnChange" property as-
Set( vrSelectedGreenColorValue, Value(Self.Text) ); Set( vrOutputColor, ColorValue( Concatenate( "#", Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_RedColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_RedColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_GreenColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_GreenColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_BlueColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_BlueColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_Alpha.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_RedColor.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ) ) ) ) );
- Click the CP_txt_BlueColor control and select Default property of textbox. Update the function as below-
If(IsBlank(vrSelectedBlueColorValue),CP_sld_BlueColor.Value,vrSelectedBlueColorValue)
- Update the same for "HintText" property as well.
- Update the "OnChange" property as-
Set( vrSelectedBlueColorValue, Value(Self.Text) ); Set( vrOutputColor, ColorValue( Concatenate( "#", Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_RedColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_RedColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_GreenColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_GreenColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_BlueColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_BlueColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_Alpha.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_RedColor.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ) ) ) ) );
- Click the CP_txt_Alpha control and select Default property of textbox. Update the function as below-
If(IsBlank(vrSelectedAlphaValue),CP_sld_AlphaColor.Value,vrSelectedAlphaValue)
- Update the same for "HintText" property as well.
- Update the "OnChange" property as-
Set( vrSelectedAlphaValue, Value(Self.Text) ); Set( vrOutputColor, ColorValue( Concatenate( "#", Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_RedColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_RedColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_GreenColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_GreenColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( Value(CP_txt_BlueColor.Text) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( Value(CP_txt_BlueColor.Text), 16 ) ).Hex ) ), Concatenate( Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_Alpha.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ), Text( LookUp( SJColorPicker.DecimalHexTable, Decimal = Mod( RoundDown( (Value(CP_txt_RedColor.Text) * 255 / 100) / 16, 0 ), 16 ) ).Hex ) ) ) ) );
- Lastly, update the "Fill" property of CP_txt_ResultColor control as "vrOutputColor".
- Save the app.
- Click on Screen tab and this component by selecting from the Insert menu.
- Save the app and run. It's working.
- Now, if you wish to get the color code of the output color, then add a button on screen and paste the below function on "OnSelect" property of button.
Set( vrOutputColorCode, Substitute( JSON( SJColorPicker_1.OutputColor, JSONFormat.IgnoreUnsupportedTypes ), Char(34), "" ) )
- Remember the "JSON" function is currently in experimental mode (as On March 05, 2023). So, you need to activate it from Settings >> Upcomin features >> Experimental.
- Add a label and set the Text property of label as "vrOutputColorCode".
- This way, you can design a basic color picker component.
With this, I am concluding this post.
Happy Coding !!!
Will see you again with some new topics.
Stay Safe !
Stay Healthy !
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.