B4J Question drawRec mysteries!

ivanomonti

Expert
Licensed User
Longtime User
I have serious problems understanding why sometimes yes and sometimes no, why the drawrect disarms me with patience,,,, it takes 10 beers each time :)

I would need to draw a frame behind each button, I can draw circles, lines, writing but not the drawrect... where is my mistake?


B4X:
For i=0 To lavagna.NumberOfViews-1
        If lavagna.GetView(i) Is Button Then
            Dim bt As Button = lavagna.GetView(i)
            x = bt.Left-20
            y = bt.Top-20
            w=bt.Width+40
            h=bt.Height+40
            Dim rec As B4XRect
            rec.Initialize(x,y,w,h)
            groupline.DrawRect(rec,xui.Color_ARGB(255,255,255,255),True,3)
            groupline.Invalidate
        End If
    Next
    groupline.DrawText("Co-Working v 0.0.1 (c) Ivano Angelo Monti 2020",140,20,timeFont,xui.Color_ARGB(125,255,255,255),"LEFT")

2020-04-15_160833.jpg
 

klaus

Expert
Licensed User
Longtime User
You should look at the documentation:
B4XRect.Initialize(Left As Float, Top As Float, Right As Float, Bottom As Float)
The two last parameters are Right and Bottom and not Width and Height!
B4X:
For i=0 To lavagna.NumberOfViews-1
        If lavagna.GetView(i) Is Button Then
            Dim bt As Button = lavagna.GetView(i)
            x = bt.Left - 20
            y = bt.Top - 20
            r = x + bt.Width + 40
            b = y + bt.Height + 40
            Dim rec As B4XRect
            rec.Initialize(x,y,r,b)
            groupline.DrawRect(rec,xui.Color_ARGB(255,255,255,255),True,3)
            groupline.Invalidate
        End If
    Next
    groupline.DrawText("Co-Working v 0.0.1 (c) Ivano Angelo Monti 2020",140,20,timeFont,xui.Color_ARGB(125,255,255,255),"LEFT")
 
Upvote 0
Top