B4J Question Button not responding to the Visible and Enable parameter

Peter Lewis

Active Member
Licensed User
Hi All

I have some buttons on my screen which are special. I have used the parameters to determine if they are visible dependant if they have any text.

I have tried to switch the button off, but it still appears and is visible and I can click it. Here is the code I am using to make it invisible and disabled.

Any ideas would be appreciated. Thank you

B4X:
    btn1.xLBL.Text=sz.GetString("Answer2")
                If btn1.xLBL.Text="" Then
                    btn1.xLBL.Visible=False
                    btn1.xLBL.Enabled=False
                End If
 

giannimaione

Well-Known Member
Licensed User
maybe sz.GetString("Answer2") is Null ?
or try:
B4X:
If btn1.xlBL.Text.Length = 0 Then
......
.....
End If
 
Upvote 0

Peter Lewis

Active Member
Licensed User
maybe sz.GetString("Answer2") is Null ?
or try:
B4X:
If btn1.xlBL.Text.Length = 0 Then
......
.....
End If
I changed all 16 places where that appeared and still have the same result. The interesting part is that it is a different colour to the normal colour I specified. I have checked the Designer and there is no other buttons in front or back of it. But i do like checking the length of the field. I will use that in future.

In this example screen comes out like this . If I did not hide the buttons they come out as grey without text. I then click on and of the blue buttons and they work (Should not ) they should not be visible and are disabled.

1589400155268.png
1589400343356.png


I had to run it twice so you can see what happens after pressing any of the buttons. Due to the questions being random and the button answers also being random , it was not the same question number or the position.

I changed the code to

B4X:
 If but4 =4 Then
        btn4.xLBL.Text=sz.GetString("Answer4")
            If btn4.xLBL.Text.Length=0 Then
                    btn4.xLBL.Visible=False
                btn4.xLBL.Enabled=False
            Else
                btn4.xLBL.Visible=True
                btn4.xLBL.Enabled=True
            End If
  
End If

I also went into designer and unchecked Visible and Enabled , but then nothing showed on the screen at all.

UPDATE:

I went into designer and made both the Primary colour and secondary colour transparent and that removed the view from the window and it is still clickable. So even though we cannot see it , someone can press the invisible button

Further UPDATE

In each button Click Sub I put in the check to see if the string length was zero and that bypassed the button code. I am sure the other method should have worked as this is a work around
 
Last edited:
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Assuming that the type of button you are using is a SwiftButton, and not a standard button, and that you want to make the button completely invisible, you should use something like btn4.mBase.Visible = ( btn4.xLBL.Text.Trim.Length > 0 )
B4X:
btn4.mBase.Visible = ( btn4.xLBL.Text.Trim.Length > 0 )     'Or
btn4.mBase.Enabled = ( btn4.xLBL.Text.Trim.Length > 0 )
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Assuming that the type of button you are using is a SwiftButton, and not a standard button, and that you want to make the button completely invisible, you should use something like btn4.mBase.Visible = ( btn4.xLBL.Text.Trim.Length > 0 )
B4X:
btn4.mBase.Visible = ( btn4.xLBL.Text.Trim.Length > 0 )     'Or
btn4.mBase.Enabled = ( btn4.xLBL.Text.Trim.Length > 0 )
Yes it is a SwiftButton . I have not tried that yet.

I do not see the option of mBase

Thank you for your advice.
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
I do not see the option of mBase
Make sure to use the latest version of XUI Views.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Make sure to use the latest version of XUI Views.
I do not have XUI Views enabled.

When I do enable it now , nothing works. If i start typing a image view box name, the option box does not appear. I have all the latest versions . I installed a clean version of B4J 2 months ago
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Ok, then you are using the class module here:

Have you seen this?
Better implementation is available in XUI Views library: [B4X] XUI Views - Cross platform views and dialogs

If you cannot leave the SwiftButton class to switch to the XUI Views library (recommended), then modify the class code and make public the mBase property.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Ok, then you are using the class module here:

Have you seen this?


If you cannot leave the SwiftButton class to switch to the XUI Views library (recommended), then modify the class code and make public the mBase property.
It was under a module called Swiftbuttons with jXUI enabled. I will look the the XUI Views . I did not see that. Thank you for showing me
 
Upvote 0
Top