Tuesday, March 7, 2023

PowerApps: Pagination Component

Hello Friends,
Welcome back with another post on PowerApps. We had discussed about pagination in some of our earlier posts. Today, we will try to create a component, which will provide the pagination feature and can be used with any gallery / data table. This component will provide you the features-
  1. To show current 10 pages (1,2...10 or 11,12...20).
  2. To show Prev / Next button with show / hide feature based upon the page you are currently visiting.
  3. To show the total number of items.
  4. To select the Page Size (number of items you want to show on one page). (Homework For You) 😊
Let's start-
  1. Login to PowerApps Maker Portal and create a new blank canvas app and give a suitable name.
  2. Click on Components and then click on "+ New component" to add a component. Set properties of component screen as-
    1. Name: SJPagination
    2. Width: 1000
    3. Height: 50
    4. Fill: RGBA(0, 0, 0, 1)
  3. Add below custom properties-
    1. Total Items
      1. Display Name: Total Items
      2. Name: TotalItems
      3. Property Type: Input
      4. Data Type: Number
    2. Page Size
      1. Display Name: Page Size
      2. Name: PageSize
      3. Property Type: Input
      4. Data Type: Number
    3. Page Number
      1. Display Name: Page Number
      2. Name: PageNumber
      3. Property Type: Output
      4. Data Type: Number
  4. Click on Component name (SJPagination from left tree view and set the default values for above input properties-
    1. TotalItems: 100
    2. PageSize: 10
  5. Add a Text label to show number of items.
    1. Name: lblTotalItems
    2. Text: Concatenate(Text(SJPagination.TotalItems)," items")
    3. Align: Align.Center
    4. LineHeight: 1
    5. X: SJPagination.Width-Self.Width
    6. Y: 0
    7. Width: 120
    8. Height: SJPagination.Height
    9. PaddingTop: 0
    10. PaddingBottom: Self.PaddingTop
    11. PaddingLeft: Self.PaddingTop
    12. PaddingRight: Self.PaddingTop
    13. Color: RGBA(0, 0, 0, 1)
    14. Fill: RGBA(255, 255, 0, 1)
  6. Add Blank horizontal gallery and set properties as below-
    1. Name: gal_BHG_Pagination
    2. X: (SJPagination.Width-Self.Width)/2
    3. Y: 0
    4. Width: lblTotalItems.X/2
    5. Height: SJPagination.Height
    6. BorderColor: SJPagination.Fill
    7. TemplateSize: Self.Width/10
    8. TemplatePadding: 0
    9. Items: Sequence(10,1,1) //Will Update Later
  7. Add a Button and set it's properties as below-
    1. Name: btnPrevious
    2. Text: "< prev"
    3. X: gal_BHG_Pagination.X-Self.Width
    4. Y: 0
    5. Width: 80
    6. Height: SJPagination.Height
    7. Fill: RGBA(0, 0, 0, 0)
    8. BorderThickness: 0
    9. RadiusTopLeft: 0
    10. RadiusTopRight: Self.RadiusTopLeft
    11. RadiusBottomLeft: Self.RadiusTopLeft
    12. RadiusBottomRight: Self.RadiusTopLeft
    13. DisabledColor: Self.Color
    14. DisabledFill: Self.Fill
    15. PressedColor: Self.Color
    16. PressedFill: Self.Fill
    17. HoverColor: lblTotalItems.Fill
    18. HoverFill: Self.Fill
  8. Add another Button and set properties as below-
    1. Name: btnNext
    2. Text: "next >"
    3. X: gal_BHG_Pagination.X+gal_BHG_Pagination.Width
    4. Y: 0
    5. Width: 80
    6. Height: SJPagination.Height
    7. Fill: RGBA(0, 0, 0, 0)
    8. BorderThickness: 0
    9. RadiusTopLeft: 0
    10. RadiusTopRight: Self.RadiusTopLeft
    11. RadiusBottomLeft: Self.RadiusTopLeft
    12. RadiusBottomRight: Self.RadiusTopLeft
    13. DisabledColor: Self.Color
    14. DisabledFill: Self.Fill
    15. PressedColor: Self.Color
    16. PressedFill: Self.Fill
    17. HoverColor: lblTotalItems.Fill
    18. HoverFill: Self.Fill
  9. Now, we will add controls in gallery (gal_BHG_Pagination). Click on Edit Template icon and add a button. Set the properties of button as below-
    1. Name: btnPageNumber
    2. Text: ThisItem.Value
    3. X: 0
    4. Y: 0
    5. Width: Parent.Width/10
    6. Height: Parent.TemplateHeight-5
    7. Color: If(ThisItem.Value=SJPagination.PageNumber,lblTotalItems.Fill,RGBA(255, 255, 255, 1))
    8. Fill: RGBA(0, 0, 0, 0)
    9. BorderThickness: 0
    10. RadiusTopLeft: 0
    11. RadiusTopRight: Self.RadiusTopLeft
    12. RadiusBottomLeft: Self.RadiusTopLeft
    13. RadiusBottomRight: Self.RadiusTopLeft
    14. DisabledColor: Self.Color
    15. DisabledFill: Self.Fill
    16. PressedColor: Self.Color
    17. PressedFill: Self.Fill
    18. HoverColor: Self.Color
    19. HoverFill: lblTotalItems.Fill
    20. OnSelect: Set(vrSelectedPageNumber,If(ThisItem.Value<=0,1,ThisItem.Value))
  10. Now add a Rectangle and set below properties-
    1. Name: rctPageNumberSelected
    2. X: 0
    3. Y: btnPageNumber.Y+btnPageNumber.Height
    4. Width: btnPageNumber.Width
    5. Height: Parent.TemplateHeight-btnPageNumber.Height
    6. Fill: If(ThisItem.Value=SJPagination.PageNumber,lblTotalItems.Fill,RGBA(0, 0, 0, 1))
  11. Our basic preparation has been done. Now, we will focus on actual functionality.
  12. First, we will set the value of PageNumber property of component. For this, click on component SJPagination and then select the PageNumber property (Output Property). Update the function as-
    1. If(
          IsBlank(vrSelectedPageNumber) || IsBlank(SJPagination.PageSize) || SJPagination.PageSize = 0,
          1,
          If(
              vrSelectedPageNumber > RoundUp(
                  SJPagination.TotalItems / SJPagination.PageSize,
                  0
              ),
              1,
              vrSelectedPageNumber
          )
      )
    2. Basically, it is first validating if vrSelectedPageNumber (currently selected page number) is blank or the PageSize property (Input property) is blank or the PageSize property is 0. If any of the condition is true, then it is setting the PageNumber property as 1 otherwise it is validating if the vrSelectedPageNumber variable value is greater than the total number of pages itself (It needs to be validated in case of filter criteria applied. For example, initially the total number of pages were 25 and the user was currently on page number 24. After applying filter criteria, the number of pages reduced to 13. In such case, there will be no page number 24. Therefore, user must be shown the records of first page). If Yes, then it is again setting the PageSize property as 1 otherwise the vrselectedPageNumber.
  13. Now, we will update the Items property of gal_BHG_Pagination gallery. Ideally, it's items must change as per the initial, previous, next condition. Means, initially, it must show 1...10. If moving to 11th page, it must show 11...20. Then, in case, moving back to 10th page, it must show 1...10 page. So, click on gal_BHG_Pagination and select the Items property from the dropdown and update the logic as below-
    1. If(
          !IsBlank(SJPagination.TotalItems) && !IsBlank(SJPagination.PageSize) && SJPagination.PageSize > 0,
          If(
              RoundUp(SJPagination.TotalItems / SJPagination.PageSize, 0) > 0,
              If(
                  SJPagination.PageNumber > RoundUp(SJPagination.TotalItems / SJPagination.PageSize, 0),
                  Sequence(10,1),
                  Sequence(
                      1 + 
                      If(
                          SJPagination.PageNumber = RoundUp(SJPagination.TotalItems / SJPagination.PageSize, 0
                          ),
                          SJPagination.PageNumber,
                          If(
                              If(
                                  Mod(SJPagination.PageNumber, 10) = 0,
                                  RoundDown(SJPagination.PageNumber / 10, 0) * 10 - 9,
                                  RoundDown(SJPagination.PageNumber / 10, 0) * 10 + 1
                              ) + 9 <= RoundUp(SJPagination.TotalItems / SJPagination.PageSize, 0),
                              If(
                                  Mod(SJPagination.PageNumber, 10) = 0,
                                  RoundDown(SJPagination.PageNumber / 10, 0) * 10 - 9,
                                  RoundDown(SJPagination.PageNumber / 10, 0) * 10 + 1
                              ) + 9,
                              RoundUp(SJPagination.TotalItems / SJPagination.PageSize, 0)
                          )
                      ) - If(
                          Mod(SJPagination.PageNumber, 10) = 0,
                          RoundDown(SJPagination.PageNumber / 10, 0) * 10 - 9,
                          RoundDown(SJPagination.PageNumber / 10, 0) * 10 + 1
                      ),
                      If(
                          Mod(SJPagination.PageNumber, 10) = 0,
                          RoundDown(SJPagination.PageNumber / 10, 0) * 10 - 9,
                          RoundDown(SJPagination.PageNumber / 10, 0) * 10 + 1
                      )
                  )
              )
          )
      )
  14. Let's understand this logic. Dividing the logic into colors to explain in better way.
    1. Color: First check if the current selected page number is greater than the total number of pages. If yes, then create a sequence of 1...10. (However, it will never show the 10 number because the Current Page Number will reset to 1, the moment total number of pages goes beyond the current page number (generally the filter case)).
    2. Color: We are adding 1 so that when the sequence function will create the page number, it starts with 1, 21, 31 and so on because 30-21 will give 9 while we need 10 number for pagination.
    3. Color: If the Current page number is equal to the Total number of pages, then use the same otherwise apply the color block.
    4. Color: This block of code is validating the end number of sequence whether it is less than or equal to the total number of pages. If yes, the use the same otherwise use the total number of page. The reason is that you cannot go beyond the total number of pages. For example if Total Items are 250 and Page Size is 10 the the Total Number of Paes are 25. So the visible pages will be 1-10, 11-20, 21-25. It cannot be 21-30.
    5. Color: It will give you the start page number of the current sequence (explanation given below for color)
    6. Color: This piece of code is defining the start number of sequence. It is saying that- If the Current Page number is 10, 20, 30... then the true part will return 1, 11, 21... otherwise false part will return 1, 11, 21... Because if the Current Page number is lying between 1 - 10, then the sequence must start with 1. Similarly, if the Current Page number lying between 11 - 20, then the sequence must start with 11.
    7. Overall Explanation: The overall objective is to create a sequence of page numbers like 1-10, 11-20, 11-30 and so on until the last page number reaches. If total pages are 40 then the last series will be 31-40. If the total pages are 46 then the last series will be 41-46.
  15. Now, we will update the OnSelect property of btnPrevious.
    1. If(
          IsBlank(vrSelectedPageNumber),
          Set(vrSelectedPageNumber, 1),
          If(
              vrSelectedPageNumber > 1,
              Set(vrSelectedPageNumber, Value(vrSelectedPageNumber) - 1)
          )
      )
  16. Similarly, update the OnSelect property of btnNext.
    1. If(
          !IsBlank(SJPagination.PageSize) && SJPagination.PageSize > 0,
          If(
              SJPagination.PageNumber < RoundUp(
                  SJPagination.TotalItems / SJPagination.PageSize,
                  0
              ),
              Set(
                  vrSelectedPageNumber,
                  SJPagination.PageNumber
              );
              Set(
                  vrSelectedPageNumber,
                  vrSelectedPageNumber + 1
              );
          )
      )
  17. Now, the Previous button must be visible only if PageNumber is greater than 1. Similarly, the Next button must be visible if the PageNumber is less than the Total Number of Pages. 
  18. Update the Visible property of btnPrevious-
    1. SJPagination.PageNumber > 1
  19. Update the Visible property of btnNext-
    1. If(
          !IsBlank(SJPagination.PageSize) && SJPagination.PageSize > 0,
          SJPagination.PageNumber < RoundUp(
              SJPagination.TotalItems / SJPagination.PageSize,
              0
          ),
          false
      )
  20. That's all. Now, go to screen tab, add a gallery add few buttons and create collection of different row counts on these buttons. Assign this collection to Items property of gallery. Add the pagination component. Set TotalItems property to rowcount of collection. Set PageSize as 10. Now play the app and test multiple scenarios.
  21. (Added Apr 01, 2023) The Items property of the gallery should be set as-
    1. Filter(FirstN(collItems,SJPagination_3.PageNumber*10),!(ID in ShowColumns(FirstN(collItems,(SJPagination_3.PageNumber-1)*10),"ID")))
  22. (Added May 22, 2023) Another fast response way to implement the Items property is -
    1. If(
          SJPagination_3.PageSize * SJPagination_3.PageNumber <= CountRows(collItems)
          ,LastN(FirstN(collItems, SJPagination_3.PageSize * SJPagination_3.PageNumber), SJPagination_3.PageSize * 1)
          ,LastN(FirstN(collItems, SJPagination_3.PageSize * SJPagination_3.PageNumber), (CountRows(collItems) - SJPagination_3.PageSize * (SJPagination_3.PageNumber - 1)))
      )
  23. Any of the Items property can be chosen. However, I would prefer the later one as it was found to be more effective, and fast as compared to former one in case of bulk data.
  24. Clicked on 80 Items Coll button.
  25. Clicked on Page No 2.
  26. Clicked on last page number (8).
  27. Clicked on 160 Items Coll button.
  28. Moved to last page of the new collection.
  29. Clicked the 80 Items Coll button again. As the current page number (16) was greater than the total number of pages (8) of new collection. The selected page number resets to 1.
  30. This is how, you can create pagination component. Now, using the output property of component "PageNumber", you can reload the collection by applying filter on datasource. Ideally, your master collection will be the separate one. From that master collection, you have to filter the desired number of items into a child collection and that child collection will be passed to the gallery items property. The pagination component's TotalItems property will be set basis upon master collection.
  31. If you wish to show the TotalItems like "1 - 10 of 80 items", then you need to make couple of changes-
    1. Add 2 buttons-
      1. Name: btnFirst (Copy of btnPrevious)
        1. Text: << first
        2. X: 0
        3. Width: 85
        4. OnSelect: Set(vrSelectedPageNumber, 1)
      2. Name: btnLast (Copy of btnNext)
        1. Text: last >>
        2. X: btnNext.X+btnNext.Width
        3. Width: 85
        4. OnSelect: Set(vrSelectedPageNumber,RoundUp(SJPagination.TotalItems / SJPagination.PageSize,0))
  32. Also, you need to update few properties of existing controls-
    1. btnPrevious.X: btnFirst.X + btnFirst.Width
    2. gal_BHG_Pagination: btnPrevious.X + btnPrevious.Width
  33. Also, you need to add 2 input properties in component-
    1. Name: FromItemNumber / DataType: Number / Default Value: 0
    2. Name: ToItemNumber / DataType: Number / Default Value: 0
  34.  Then you need to update the lblTotalItems controls as-
    1. Text: If(
          SJPagination.TotalItems > 0
          ,SJPagination.FromItemNumber & " - " & SJPagination.ToItemNumber & " of " & SJPagination.TotalItems & " item" & If(SJPagination.TotalItems > 1, "s")
          ,"0 items"
      )
      
    2. Width: 220
    3. Size: 12 (Font size)
  35. Coming back to Screen, where the component is used, we have to give input values to the 2 input parameters we had created.
  36. FromItemNumber : If(CountRows(collItems) > 0, ((SJPagination_3.PageNumber - 1)* SJPagination_3.PageSize + 1), 0)
  37. ToItemNumber : (((SJPagination_3.PageNumber - 1) * SJPagination_3.PageSize) + Gallery1_1.AllItemsCount)
  38. Save the app and play-
  39. Default-
  40. Next-
  41. Last-
  42. Previous-
  43. First-
  44. In case, if you wish to provide Page Size option as well, then you need to add a dropdown and wherever we have used 10 as static value for PageSize, use the selected value of dropdown. Also change the type of PageSize property from Input to Output.
With this, I am concluding this post.
Happy Coding !!!
Will see you again with some new topics.

Stay Safe !
Stay Healthy !

Sunday, March 5, 2023

PowerApps: Color Picker Component

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.

  1. Login to PowerApps Maker Portal. Create a new app and provide as suitable name.
  2. 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.
  3. Give component a suitable name. I am using "SJColorPicker'.
  4. Set the size of component as-
    1. Width: 250
    2. Height: 140 
  5. Add a rectangle to give your component a border.
    1. Name: CP_rct_Border
    2. X: 0
    3. Y: 0
    4. Width: SJColorPicker.Width
    5. Height: SJColorPicker.Height
    6. Fill: Color.Transparent
    7. BorderColor: Color.Black
    8. BorderSyle: BorderStyle.Solid
    9. BorderThickness: 1
  6. Add a TextInput control for Red Color.
    1. Name: CP_txt_RedColor
    2. Default: "127"
    3. Format: Number
    4. Size: Self.Height*35%
    5. Align: Align.Center
    6. LineHeight: 1
    7. X: CP_rct_Border.X+CP_rct_Border.BorderThickness
    8. Y: CP_rct_Border.Y+CP_rct_Border.BorderThickness
    9. Width: (SJColorPicker.Width-2*CP_rct_Border.BorderThickness)/5
    10. Height: (SJColorPicker.Height-2*CP_rct_Border.BorderThickness)/5
    11. PaddingTop: 5
    12. PaddingBottom: Self.PaddingTop
    13. PaddingLeft: Self.PaddingTop
    14. PaddingRight: Self.PaddingTop
    15. Color: RGBA(0, 0, 0, 1)
    16. Fill: RGBA(255, 255, 255, 1)
    17. BorderColor: Color.Black
    18. BorderSyle: BorderStyle.Solid
    19. BorderThickness: 1
    20. RadiusTopLeft: 0
    21. RadiusTopRight: Self.RadiusTopLeft
    22. RadiusBottomLeft: Self.RadiusTopLeft
    23. RadiusBottomRight: Self.RadiusTopLeft
    24. DisabledBorderColor: Self.BorderColor
    25. DisabledColor: Self.Color
    26. DisabledFill: Self.Fill
    27. HoverBorderColor: Self.BorderColor
    28. HoverColor: Self.Color
    29. HoverFill: Self.Fill
    30. PressedBorderColor: Self.BorderColor
    31. PressedColor: Self.Color
    32. PressedFill: Self.Fill
  7. Now, add a TextInput control for Green Color.
    1. Name: CP_txt_GreenColor
    2. Default: "127"
    3. Format: Number
    4. Size: Self.Height*35%
    5. Align: Align.Center
    6. LineHeight: 1
    7. X: CP_txt_RedColor.X+CP_txt_RedColor.Width
    8. Y: CP_rct_Border.Y+CP_rct_Border.BorderThickness
    9. Width: (SJColorPicker.Width-2*CP_rct_Border.BorderThickness)/5
    10. Height: (SJColorPicker.Height-2*CP_rct_Border.BorderThickness)/5
    11. PaddingTop: 5
    12. PaddingBottom: Self.PaddingTop
    13. PaddingLeft: Self.PaddingTop
    14. PaddingRight: Self.PaddingTop
    15. Color: RGBA(0, 0, 0, 1)
    16. Fill: RGBA(255, 255, 255, 1)
    17. BorderColor: Color.Black
    18. BorderSyle: BorderStyle.Solid
    19. BorderThickness: 1
    20. RadiusTopLeft: 0
    21. RadiusTopRight: Self.RadiusTopLeft
    22. RadiusBottomLeft: Self.RadiusTopLeft
    23. RadiusBottomRight: Self.RadiusTopLeft
    24. DisabledBorderColor: Self.BorderColor
    25. DisabledColor: Self.Color
    26. DisabledFill: Self.Fill
    27. HoverBorderColor: Self.BorderColor
    28. HoverColor: Self.Color
    29. HoverFill: Self.Fill
    30. PressedBorderColor: Self.BorderColor
    31. PressedColor: Self.Color
    32. PressedFill: Self.Fill
  8. Now, add a TextInput control for Blue Color.
    1. Name: CP_txt_BlueColor
    2. Default: "127"
    3. Format: Number
    4. Size: Self.Height*35%
    5. Align: Align.Center
    6. LineHeight: 1
    7. X: CP_txt_GreenColor.X+CP_txt_GreenColor.Width
    8. Y: CP_rct_Border.Y+CP_rct_Border.BorderThickness
    9. Width: (SJColorPicker.Width-2*CP_rct_Border.BorderThickness)/5
    10. Height: (SJColorPicker.Height-2*CP_rct_Border.BorderThickness)/5
    11. PaddingTop: 5
    12. PaddingBottom: Self.PaddingTop
    13. PaddingLeft: Self.PaddingTop
    14. PaddingRight: Self.PaddingTop
    15. Color: RGBA(0, 0, 0, 1)
    16. Fill: RGBA(255, 255, 255, 1)
    17. BorderColor: Color.Black
    18. BorderSyle: BorderStyle.Solid
    19. BorderThickness: 1
    20. RadiusTopLeft: 0
    21. RadiusTopRight: Self.RadiusTopLeft
    22. RadiusBottomLeft: Self.RadiusTopLeft
    23. RadiusBottomRight: Self.RadiusTopLeft
    24. DisabledBorderColor: Self.BorderColor
    25. DisabledColor: Self.Color
    26. DisabledFill: Self.Fill
    27. HoverBorderColor: Self.BorderColor
    28. HoverColor: Self.Color
    29. HoverFill: Self.Fill
    30. PressedBorderColor: Self.BorderColor
    31. PressedColor: Self.Color
    32. PressedFill: Self.Fill
  9. Now, add a TextInput control for Alpha. Alpha value is used for transparency. 0 means transparent while 100% means opaque.
    1. Name: CP_txt_Alpha
    2. Default: "50"
    3. Format: Number
    4. Size: Self.Height*35%
    5. Align: Align.Center
    6. LineHeight: 1
    7. X: CP_txt_BlueColor.X+CP_txt_BlueColor.Width
    8. Y: CP_rct_Border.Y+CP_rct_Border.BorderThickness
    9. Width: (SJColorPicker.Width-2*CP_rct_Border.BorderThickness)/5
    10. Height: (SJColorPicker.Height-2*CP_rct_Border.BorderThickness)/5
    11. PaddingTop: 5
    12. PaddingBottom: Self.PaddingTop
    13. PaddingLeft: Self.PaddingTop
    14. PaddingRight: Self.PaddingTop
    15. Color: RGBA(0, 0, 0, 1)
    16. Fill: RGBA(255, 255, 255, 1)
    17. BorderColor: Color.Black
    18. BorderSyle: BorderStyle.Solid
    19. BorderThickness: 1
    20. RadiusTopLeft: 0
    21. RadiusTopRight: Self.RadiusTopLeft
    22. RadiusBottomLeft: Self.RadiusTopLeft
    23. RadiusBottomRight: Self.RadiusTopLeft
    24. DisabledBorderColor: Self.BorderColor
    25. DisabledColor: Self.Color
    26. DisabledFill: Self.Fill
    27. HoverBorderColor: Self.BorderColor
    28. HoverColor: Self.Color
    29. HoverFill: Self.Fill
    30. PressedBorderColor: Self.BorderColor
    31. PressedColor: Self.Color
    32. PressedFill: Self.Fill
  10. Now, add a TextInput control for Output color. This text box will be used to show the result color based upon the RGBA selected.
    1. Name: CP_txt_ResultColor
    2. Default: ""
    3. Format: Text
    4. Size: Self.Height*35%
    5. Align: Align.Center
    6. LineHeight: 1
    7. DisplayMode: DisplayMode.Disabled
    8. X: CP_txt_Alpha.X+CP_txt_Alpha.Width
    9. Y: CP_rct_Border.Y+CP_rct_Border.BorderThickness
    10. Width: (SJColorPicker.Width-2*CP_rct_Border.BorderThickness)/5
    11. Height: (SJColorPicker.Height-2*CP_rct_Border.BorderThickness)/5
    12. PaddingTop: 5
    13. PaddingBottom: Self.PaddingTop
    14. PaddingLeft: Self.PaddingTop
    15. PaddingRight: Self.PaddingTop
    16. Color: RGBA(0, 0, 0, 1)
    17. Fill: RGBA(255, 255, 255, 1)
    18. BorderColor: Color.Black
    19. BorderSyle: BorderStyle.Solid
    20. BorderThickness: 1
    21. RadiusTopLeft: 0
    22. RadiusTopRight: Self.RadiusTopLeft
    23. RadiusBottomLeft: Self.RadiusTopLeft
    24. RadiusBottomRight: Self.RadiusTopLeft
    25. DisabledBorderColor: Self.BorderColor
    26. DisabledColor: Self.Color
    27. DisabledFill: Self.Fill
    28. HoverBorderColor: Self.BorderColor
    29. HoverColor: Self.Color
    30. HoverFill: Self.Fill
    31. PressedBorderColor: Self.BorderColor
    32. PressedColor: Self.Color
    33. PressedFill: Self.Fill
  11. 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.
  12. Add, a slider control for Red color.
    1. Name: CP_sld_RedColor
    2. Default: If(IsBlank(vrSelectedRedColorValue),127,vrSelectedRedColorValue)
    3. Max: 255
    4. Min: 0
    5. ShowValue: false
    6. HandleSize: Self.Height*60%
    7. X: CP_txt_RedColor.X
    8. Y: CP_txt_RedColor.Y+CP_txt_RedColor.Height
    9. Width: SJColorPicker.Width-2*CP_rct_Border.BorderThickness
    10. Height: CP_txt_RedColor.Height
    11. ValueFill: RGBA(255, 0, 0, 1)
  13. Add, a slider control for Green color.
    1. Name: CP_sld_GreenColor
    2. Default: If(IsBlank(vrSelectedGreenColorValue),127,vrSelectedGreenColorValue)
    3. Max: 255
    4. Min: 0
    5. ShowValue: false
    6. HandleSize: Self.Height*60%
    7. X: CP_txt_RedColor.X
    8. Y: CP_sld_RedColor.Y+CP_sld_RedColor.Height
    9. Width: SJColorPicker.Width-2*CP_rct_Border.BorderThickness
    10. Height: CP_txt_RedColor.Height
    11. ValueFill: RGBA(0, 255, 0, 1)
  14. Add, a slider control for Blue color.
    1. Name: CP_sld_BlueColor
    2. Default: If(IsBlank(vrSelectedBlueColorValue),127,vrSelectedBlueColorValue)
    3. Max: 255
    4. Min: 0
    5. ShowValue: false
    6. HandleSize: Self.Height*60%
    7. X: CP_txt_RedColor.X
    8. Y: CP_sld_GreenColor.Y+CP_sld_GreenColor.Height
    9. Width: SJColorPicker.Width-2*CP_rct_Border.BorderThickness
    10. Height: CP_txt_RedColor.Height
    11. ValueFill: RGBA(0, 0, 255, 1)
  15. Add, a slider control for Alpha.
    1. Name: CP_sld_Alpha
    2. Default: If(IsBlank(vrSelectedAlphaValue),50,vrSelectedAlphaValue)
    3. Max: 100
    4. Min: 0
    5. ShowValue: false
    6. HandleSize: Self.Height*60%
    7. X: CP_txt_RedColor.X
    8. Y: CP_sld_BlueColor.Y+CP_sld_BlueColor.Height
    9. Width: SJColorPicker.Width-2*CP_rct_Border.BorderThickness
    10. Height: CP_txt_RedColor.Height
    11. ValueFill: RGBA(0, 0, 0, 1)
  16. 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".
  17. Add an Input Property-
    1. Display Name: Decimal-Hex Table
    2. Name: DecimalHexTable
    3. Property type: Input
    4. Data type: Table
  18. Click on Save. Now click on this property to set it's default value.
  19. Replace the current display table with below one-
    1. 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"
          }
      )
  20. This table will be used to convert Decimal value to Hex and vice-versa.
  21. Add another custom property. This time it would type of Output.
    1. Display Name: Output Color
    2. Name: OutputColor
    3. Property type: Output
    4. Data type: Color
  22. Click on Save. Now click on this property to set it's default value. Change the default value to "vrOutputColor".
  23. Now we will start applying functionality for "OnChange" event of each control.
  24. Click on CP_sld_Alpha and choose OnChange property. Update the function as-
    1. 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
                      )
                  )
              )
          )
      );
      
  25. Click on CP_sld_BlueColor and choose OnChange property. Update the function as-
    1. 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
                      )
                  )
              )
          )
      );
      
  26. Click on CP_sld_GreenColor and choose OnChange property. Update the function as-
    1. 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
                      )
                  )
              )
          )
      );
      
  27. Click on CP_sld_RedColor and choose OnChange property. Update the function as-
    1. 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
                      )
                  )
              )
          )
      );
  28. Now, we will update the "Default", "HintText", "OnChange" properties of the text boxes.
  29. Click the CP_txt_RedColor control and select Default property of textbox. Update the function as below-
    1. If(IsBlank(vrSelectedRedColorValue),CP_sld_RedColor.Value,vrSelectedRedColorValue)
  30. Update the same for "HintText" property as well.
  31. Update the "OnChange" property as-
    1. 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
                      )
                  )
              )
          )
      );
  32. Click the CP_txt_GreenColor control and select Default property of textbox. Update the function as below-
    1. If(IsBlank(vrSelectedGreenColorValue),CP_sld_GreenColor.Value,vrSelectedGreenColorValue)
  33. Update the same for "HintText" property as well.
  34. Update the "OnChange" property as-
    1. 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
                      )
                  )
              )
          )
      );
      
  35. Click the CP_txt_BlueColor control and select Default property of textbox. Update the function as below-
    1. If(IsBlank(vrSelectedBlueColorValue),CP_sld_BlueColor.Value,vrSelectedBlueColorValue)
  36. Update the same for "HintText" property as well.
  37. Update the "OnChange" property as-
    1. 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
                      )
                  )
              )
          )
      );
      
  38. Click the CP_txt_Alpha control and select Default property of textbox. Update the function as below-
    1. If(IsBlank(vrSelectedAlphaValue),CP_sld_AlphaColor.Value,vrSelectedAlphaValue)
  39. Update the same for "HintText" property as well.
  40. Update the "OnChange" property as-
    1. 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
                      )
                  )
              )
          )
      );
      
  41. Lastly, update the "Fill" property of CP_txt_ResultColor control as "vrOutputColor".
  42. Save the app.
  43. Click on Screen tab and this component by selecting from the Insert menu.
  44. Save the app and run. It's working.
  45. 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.
    1. Set(
          vrOutputColorCode,
          Substitute(
              JSON(
                  SJColorPicker_1.OutputColor,
                  JSONFormat.IgnoreUnsupportedTypes
              ),
              Char(34),
              ""
          )
      )
    2. 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.
  46. Add a label and set the Text property of label as "vrOutputColorCode".
  47. 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 !