Android Question help needed - how to disable a panel and its elements

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
i have a view (panel) in B4A app
i display another panel ontop
the top panel is partly transparent so the under panel is visible
how can i grab the under panel's name to identify it (it can be one of many in my app)
and then disable it and after i am done to re-enable it?
otherwise the user can still click any button in the background pannel
i want only the top one to be active
in windows i can show a modal form or topmost form - how can i do it in b4a?
thanks
 

DonManfred

Expert
Licensed User
Longtime User
Away from that @LucaMs is right.

One thread in this Forum should Summarize one Question. This is a basic Forumrule here for years now.
If you have more than one question you should create multiple Threads. One for each Question.
 
Upvote 0

Spavlyuk

Active Member
Licensed User
the flow is very complex so i cannot do that
Unfortunately I don't think there's another solution, so it's up to you to either write a new dialog library or update your existing code.
The latter seems to be the easier choice. I may be wrong but it seems like you would only have to create an additional sub and paste the code that handles the result into it...

B4X:
Sub Activity_Resume
    If ShouldShowDialog Then
        Msgbox2Async("Question?", "Title", "Yes", "Cancel", "No", Null, False)
        Wait For Msgbox_Result (Result As Int)
        HandleResult(Result)
    End If
End Sub

Sub View_Click
        ShouldShowDialog = True
        Msgbox2Async("Question?", "Title", "Yes", "Cancel", "No", Null, False)
        Wait For Msgbox_Result (Result As Int)
        HandleResult(Result)
End Sub

Sub HandleResult(Result As Int)
    ShouldShowDialog = False
    ' Paste code that handles the result here
End Sub
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
thank you all who tried to help me
no solution offered worked or could work as i can't break the app's flow and any solution as good as it is couldn't work as i can't hold and wait the flow for a form/view to operate so it is all nice but i can't use any of them

i'm afraid i will have as @DonManfred suggested and quit this long topic and try to find an alternative dialog mechanism if any exists

once again - thank you all
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Is this what you are looking for ?
It is your project from post #14.
I changed this line:
pnlDialog.Initialize("")
to this:
pnlDialog.Initialize("pnlDialog")

And added this sub:
Private Sub pnlDialog_Click
Log("3")
End Sub

And i added some Logs to see what happens.
 

Attachments

  • zDialog3.zip
    10 KB · Views: 127
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Thanks Klaus
The main issue is that currently I use dialog so the flow is holding and wait for the dialog to return so then I can upon the result go right or left

When using this panel the flow doesn't stop and wait so yes, the view is displayed but the calling code moved on and I can't process the result

This is the big issue
It happens when there's a dialog displayed and a phone call comes in, then when going back to the app the dialog is gone and there is noway to get back
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
when there's a dialog displayed and a phone call comes in, then when going back to the app the dialog is gone
Not sure but... you're not using B4XPages, right? I think this would not happend with B4XPages.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Without seeing exactly your program flow it is impossible to give a good advice.
Klause,

as promissed - here is a simple sample
it's a b4a code not b4x - my app is very old and huge so we kept it as it was
it's live with many users so i didn't want to "play" with it

run it
clicj the button to open the dialog
and then simply push it to background by home key or incoming call
the reload it from task manager
you will see that thew dialog is gone and the app is like restarting so whatever i was in the middle is gone as it skipped the dialog

any suggestin is welcome
if i need to mix with b4x please do tell me what to do

thanks
 

Attachments

  • DialogSample.zip
    95.3 KB · Views: 103
Upvote 0

josejad

Expert
Licensed User
Longtime User
Did this project work for you?

 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Please, try this project. I've used msgbox2async (msgbox should be avoid, see #6)

Take a look to Resumable Subs too

I've just used a variable to save the state, and check that variable in Active_Resume.

it's worth it to wait comments from Klause, this solution may have some drawbacks
 

Attachments

  • DialogSample_.zip
    9.3 KB · Views: 107
Upvote 0

klaus

Expert
Licensed User
Longtime User
I am not sure if the solution above will solve the problem.
In the simple example calling the Button_Click event in Activity_Resume works only in this case.
If there are calls from different buttons it will not work.
I added in the project above a second button with another Button_Click event.
To distinguish between the two calls i added a string variable with the name of the routine to call.
But depending on the program flow of the big project i am not sure if this is enough.
Maybe other information need to be saved and recalled.
 

Attachments

  • DialogSample1.zip
    9.4 KB · Views: 107
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
I am not sure if the solution above will solve the problem.
In the simple example calling the Button_Click event in Activity_Resume works only in this case.
If there are calls from different buttons it will not work.
I added in the project above a second button with another Button_Click event.
To distinguish between the two calls i added a string variable with the name of the routine to call.
But depending on the program flow of the big project i am not sure if this is enough.
Maybe other information need to be saved and recalled.

thank you Jose & Klaus
the latest solution seems to have a good petential as it seems to me to work
i will go through a deeper test including in my monster app and will revert soon

once again thank you so much for your good will
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
ok

i did the test
when activating the solution from a button as in the sample it works perfectly (!!)

but
my app doesn't load the msgbox from a button click
the flow is something like this -

there is a long section of code lines (in a sub), then in the middle there is a junction where i need this msgdialog
after another part of lines, still same sub, or even another one - another juction to show the msgdialog
so there is no way for me to pinpoint the exact locatiob to resume

something like this:

line
line
line
msgdialog
if
then
else

line
line
line
if
then
else

etc

i'm getting frustrated and desperate :(
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
This is what i was afraid of when i wrote this sentence:
But depending on the program flow of the big project i am not sure if this is enough.

In this case you could perhaps split the routine in several subroutines.
The first calling the second depending on the answer and the second calls the third on e and so on.
But it gives you entry points depending on the previous conditions.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
This is what i was afraid of when i wrote this sentence:
But depending on the program flow of the big project i am not sure if this is enough.

In this case you could perhaps split the routine in several subroutines.
The first calling the second depending on the answer and the second calls the third on e and so on.
But it gives you entry points depending on the previous conditions.
Wow
That will be crazy
It's a huge app, really huge and such an idea is just not doable as I have so many places with that issue

The best could be if I could use a panel based solution but to be able to hold the calling code until I have an answer and closed the panel/view with the dialog

Or any other kind of msgdialog that will wait and not disappear in case of interference like incoming calls

I can't understand rhat crazy behavior...
 
Upvote 0

josejad

Expert
Licensed User
Longtime User

Attachments

  • FormsTest.zip
    9.7 KB · Views: 79
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Ok, try this.
Check the "Platform specific instructions" for B4XPreferencesDialog (manifest)
thanks Jose
i think i might of missed someting

i did not understand what to look for in manifest...

i saw your sample - i need a different type of msgdialog (your's worked)
no need for the combo box on the top right at all
need to be able to change the title programmatically
need to add text in the msgdialog

can it all be done without the json?

that looks like it may be the right solution for me...
many thans
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
thanks Jose
i think i might of missed someting

i did not understand what to look for in manifest...

i saw your sample - i need a different type of msgdialog (your's worked)
no need for the combo box on the top right at all
need to be able to change the title programmatically
need to add text in the msgdialog

can it all be done without the json?

that looks like it may be the right solution for me...
many thans
i tried to omit the json loading - worked
but how do i add title & message?
any way to change buttons text?
show or hide a button?
set the background to light?

this is really looking like the solution i needed

EDIT:
got control on the buttons - brilliant!! - text change easy and hide a button easy - in calling

got control on theme
nw the only thing is how to add title and text

this IS my solution!!
 
Last edited:
Upvote 0
Top