B4J Question [SOLVED] xui.PaintOrColorToColor - reverse function?

Discussion in 'B4J Questions' started by LucaMs, Jul 18, 2019.

  1. LucaMs

    LucaMs Expert Licensed User

    How to get a Paint (?) if you have an int variable set using xui.PaintOrColorToColor?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You don't want to get a paint when working with XUI. Only ints.

    If you do want to get a paint for some strange reason then:
    Code:
    Dim p as Paint = fx.Colors.From32Bit(0xffff0000)
     
    LucaMs likes this.
  3. LucaMs

    LucaMs Expert Licensed User

    The reason is very clear: I'm a bit confused :D:(

    Actually what I'm doing is saving a map of preferences (using B4XSerializator) and one of them is the MainForm back color, which is a Paint object.

    Code:
    mMainFormColor = mmapPref.GetDefault("MainFormColor", xui.Color_Green)
    At this point I don't know how to set the MainForm.BackColor to mMainFormColor.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    IntColor = fx.Colors.To32Bit(MainForm.BackColor)
     
    LucaMs likes this.
  5. Erel

    Erel Administrator Staff Member Licensed User

    I'm confused.

    This code is also correct:
    Code:
    IntColor = XUI.PaintOrColorToColor(MainForm.BackColor)
     
    LucaMs likes this.
  6. LucaMs

    LucaMs Expert Licensed User

    But I have to set the MainForm.BackColor, not get it.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Form.BackColor = fx.Colors.From32Bit(mmapPref.GetDefault("MainFormColor", xui.Color_Green))
     
    LucaMs likes this.
  8. LucaMs

    LucaMs Expert Licensed User

    I was thinking to that From32bit... about how to convert my Int to... 32bit :D:eek::rolleyes:
     
    Erel likes this.
  9. LucaMs

    LucaMs Expert Licensed User

    (here it is nearly a different question... I don't know if I should open a new thread).

    I tried directly:

    MainForm.BackColor = fx.Colors.From32Bit(xui.Color_Blue)

    but this has no effects.

    Strangely, BackColor requires a Paint object and From32Bit returns a javafx.scene.paint.Color, which is accepted but, as I said, the MainForm back color does not change.
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    The color is represented as 4 bytes (ARGB) = 32 bits.
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Works fine here:
    Code:
    MainForm.BackColor = fx.Colors.From32Bit(xui.Color_Blue)
    Dim x As B4XView = MainForm.RootPane
    x.Color = xui.Color_Transparent
    The real question is why do you need to set BackColor. Set MainForm.RootPane color instead.
     
    LucaMs likes this.
  12. LucaMs

    LucaMs Expert Licensed User

    Because I "searched" a property to set the RootPane color but I didn't find it (right now I found "Style", I think I should use it).
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    Don't. Use B4XView as I did in the post above.
     
    LucaMs likes this.
  14. LucaMs

    LucaMs Expert Licensed User

    Done (although I have not understood its functioning well :D)
     
  15. Erel

    Erel Administrator Staff Member Licensed User

    Very simple.

    Code:
    Dim x As B4XView = AnyViewType
    'work with x
     
    LucaMs likes this.
  16. LucaMs

    LucaMs Expert Licensed User

    Yes but this is the part I don't understand:
     
    Last edited: Jul 18, 2019
  17. Erel

    Erel Administrator Staff Member Licensed User

    I wanted to test whether the BackColor works. You need to set the root pane color to transparent in order to see the back color.
     
    LucaMs likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice