Bug? Bug in B4XView.Enabled ?

Filippo

Expert
Licensed User
Longtime User
Hi,

I have found an error in the “Enabled” property.
This B4x code returns incorrect results in B4i, but returns the correct result in B4a.

Here is the B4x code:
B4X:
    Log(" Test ")
    Dim lblPlus, lblMinus As Label
    lblPlus.Initialize("")
    lblMinus.Initialize("")
    
    lblPlus.As(B4XView).Enabled = 5 < 4
    lblMinus.As(B4XView).Enabled = 10 > 1
    
    Log("lblPlus.As(B4XView).Enabled = " & lblPlus.As(B4XView).Enabled)
    Log("lblMinus.As(B4XView).Enabled = " & lblMinus.As(B4XView).Enabled)
    
    Log("5 < 4 =" & (5 < 4))
    Log("1 < 10 =" & (1 < 10))
    Log(" ")

Log output in B4i:
Test
lblPlus.As(B4XView).Enabled = true
lblMinus.As(B4XView).Enabled = true
5 < 4 =false
1 < 10 =true

Log output in B4a:
Test
lblPlus.As(B4XView).Enabled = false
lblMinus.As(B4XView).Enabled = true
5 < 4 =false
1 < 10 =true
 

Filippo

Expert
Licensed User
Longtime User
B4X:
    lblPlus.As(B4XView).Enabled = False
    lblMinus.As(B4XView).Enabled = True

works?

And:
B4X:
    lblPlus.Enabled = 5 < 4
    lblMinus.Enabled = 10 > 1
?
1. No
2. No

But even if it works like this, why does the same code work in B4a and not in B4i?
 

aeric

Expert
Licensed User
Longtime User
I think because the Label view in B4i doesn't support it and the value will always return True.

1732635814967.png
 

aeric

Expert
Licensed User
Longtime User
That is when you declare some "native" View as B4XView; but Label has the Enabled property.

EDIT: Unless B4i Label does not have that property :oops: , I can't know it.

Yes, in B4A Designer, you can find Enabled property.
1732638812114.png


But in B4i, you don't find this property.
1732638884566.png
 

Filippo

Expert
Licensed User
Longtime User
But shouldn't it be the case that such basic functionalities are the same on a multiplatform?
I can understand it for specific functionalities, but this is about a basic function.

But it's all good, I was able to solve the problem.
But I think that many other users may encounter the same problem and not immediately realize that something is not working.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I think because the Label view in B4i doesn't support it and the value will always return True.

View attachment 158927
This is the correct answer.

B4X is based on the native views. B4XView is a cross platform API layer that allows accessing the native views through a common API. The documentation states differences between the platforms (not 100% clear in this specific case).

Most of iOS/B4i views do not have an enabled property.
 
Top