Android Question Msgbox2 buttons (Msgbox2Async)

Sergey_New

Well-Known Member
Licensed User
Longtime User
Can you please tell me how to disable uppercase in the button names for Msgbox2 (Msgbox2Async).
I used to see a way on the forum, but now I can not find it by searching for the word "allcaps".
I would also like to know how to change the position of the buttons.
 

zed

Active Member
Licensed User
Use B4XDialog

and create template for B4XDialog
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Thanks, that's understandable.
What can be said on the merits of the questions?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
How do you declare the Msgbox2.
In the declaration you have:
B4X:
Msgbox2Async (Message As CharSequence, Title As CharSequence, Positive As String, Cancel As String, Negative As String, Icon As BitmapWrapper, Cancelable As Boolean)
And the texts displayed in the buttons are those you give in Positive, Cancel and Negative.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
And the texts displayed in the buttons are those you give in Positive, Cancel and Negative.
The text is displayed in upper case: POSITIVE, CANCEL, NEGATIVE.
Lowercase required. I saw on the forum how to do it in the manifest but can't find it.
I would also like to know how to change the position of the buttons without changing their return value.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
@Sergey_New
As you need some customizations, I would create a Panel to act as a MsgBox so you can create it as you wish in every aspect.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
I would not want to reinvent the wheel if there are known solutions. :)
I agree.
As you said probably there is a way to obtain the lower case text.
But then I don't know how to change the choices order (if I understood well what you want).
For that maybe you will just need to manage them apart from what they really are:
Positive = you will manage it as Negative
Cancel = you will manage it as Positive
and so on.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Manifest Editor:
CreateResource(values-v21, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
        <item name="android:textAllCaps">false</item>
    </style>   
</resources>
)

B4X:
Private Sub Button1_Click
    Dim sf As Object = xui.Msgbox2Async("Delete file?", "Title", "Cancel", "No", "Yes", Null)
    Wait For (sf) Msgbox_Result (Result As Int)
    If Result = xui.DialogResponse_Negative Then
        Log("Yes is selected")
    Else If Result = xui.DialogResponse_Cancel Then
        Log("No is selected")
    Else
        Log("Cancel is selected")
    End If
End Sub
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User

aeric,​

Thanks a lot! This is exactly the way I was looking for. Works as desired.
Only earlier I found similar code that changed the case only for Msgbox2. From memory, the term "Alert" was used there.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Take note that the manifest may change all the styles not only for the alert button. I am not familiar with manifest. I just tested and it just works. Maybe there is better settings.
Also good to be aware that the capitalization is part of Material design standard so if you are following the standard, then you should use the recommended style as mentioned in many replies in Stack Overflow.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Aeric, thanks, I understand you.
When asked how to change the position of the buttons without changing their return value, no one answered.
Does it look like it's impossible?
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
how to change the position of the buttons without changing their return value, no one answered.
What do you mean by changing the position of the buttons without changing their return value? You mean you can customize how many pixels Left and Top?

Isn't my example answers your question?
It doesn't matter what the return values are, you can do whatever you want after the return value.

I think it is not easy to customise the build-in or default behaviour of Android widget. You need some hacking like modifying the manifest. I don't use the msgbox in my app as it looks ugly in B4J. I would use other Dialog such as B4XPreferenceDialog where I can easily customize what I want.
 
Upvote 0
Top