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
 

Sagenut

Expert
Licensed User
Longtime User
Do you want the partially transparent panel on top to block click to the underlying one?
Just create the Touch event for the transparent panel and it will consume the click avoiding the underlying things to be touched.
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
add for the top panel a _Click event and it will catch all presses on it and prevent presses on views under it.

B4X:
Private Sub Panel1_Click
    'do nothing
End Sub

like this you dont need to enable/disable anything.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
pals,
thank you all for posting help for me
it seems this will not do as what i need is a dialog that stays on top without being auto closed when the app is interrupted say for a phone call - in this case when a phone call comes in and my app displays a dialog of any kind when the app returns the dialog is gone
another form on top wont really do as the entire flow breaks - i tried something with resumable but did not do what i needed
so once again - i ask for a solution to a dialog that stays on screen as modal so when the app returns it will return exactly to the display before including the dialog
what kind of dialog?
i don't really care as any kind that will allow me do that espessially where i can inspect the return value from the button the user pressed in the dialog (for example a confirm dialog that shows a message and 2 buttons "yes" & "no" and when returned i will know if it was a yes or no - boolean ? all is ok)
thanks
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
pals,
thank you all for posting help for me
it seems this will not do as what i need is a dialog that stays on top without being auto closed when the app is interrupted say for a phone call - in this case when a phone call comes in and my app displays a dialog of any kind when the app returns the dialog is gone
What is the reason you totally miss that information in #1 leaving us in the dark?
React on Appevents. If a dialog is open remember it was to show it again after the app resumes.
i ask for a solution to a dialog that stays on screen as modal so when the app returns it will return exactly to the display before including the dialog
what kind of dialog?
there is no such thing
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
What is the reason you totally miss that information in #1 leaving us in the dark?
React on Appevents. If a dialog is open remember it was to show it again after the app resumes.

there is no such thing
i think it took me some time to really get into it
doing as you suggested i think wont work as the entire flow breaks - the app will return to the previous view but not the code so if i display the dialog again then the result is somewhere lost as the relevant waiting for it is lost and the app went on
if only i could get a sign that this had happened i could easily loop the dialog but it seems that when return it is like something was preesed but none of the options and my code will not know where it happedned
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
What is the reason you totally miss that information in #1 leaving us in the dark?
React on Appevents. If a dialog is open remember it was to show it again after the app resumes.

there is no such thing
as per the second part - how do you all handles such events?
is there, alternatively, a way to block incoming phone call so there will be no interruptions on the critical part?
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
is there, alternatively, a way to block incoming phone call so there will be no interruptions on the critical part?
don't block incoming calls, this is a bad idea!

you can use the Activity_Pause to store your app stat on a public object (maybe map) :

B4X:
Sub Activity_Pause (UserClosed As Boolean)

End Sub

when you return check in Activity_Resume that object and show the dialog if needed. all entered data can also be stored on that map.

B4X:
Sub Activity_Resume

End Sub
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
don't block incoming calls, this is a bad idea!

you can use the Activity_Pause to store your app stat on a public object (maybe map) :

B4X:
Sub Activity_Pause (UserClosed As Boolean)

End Sub

when you return check in Activity_Resume that object and show the dialog if needed. all entered data can also be stored on that map.

B4X:
Sub Activity_Resume

End Sub
thanks
i did try this approach and i use it
i identify on resume that i was already in the app and i return to the same form/panel
including all fields with their values an i don't reset it
that's fine
but the place i was is lost
so if i was in a junction for yes or no and displays a dialog to ask the user that is lost and the app returns to the last view it was on
if i could at least hold the exact location so when returning i will be returning to the same place it would be perfect
there is not much of a point to redisplay a dialog when the decission junction is lost
i even tried resumable and many crazy ideas - nothing worked - when it resumes it resumes to the right view but not to the right place so i can't just redisplay the dialog
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
create your own dialog using simple panels, textviews and buttons. like you can return to any page in that dialog.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
tried that
i have the dialog view working fine
but there is no option after i display it and one of the buttons is clicked to return to the calling place so once again i lose my flow
if i could on the button click return as from a dialog it would be perfect
naturally holding as resumable does not work here
that could be the best as nothing is lost in that way except the return to the calling routine
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
i dont understand your issue. you said on first post that you have a problem when you click on buttons and the views behind that panel are triggered then you wrote that when app closes you loose your stats now you have an issue inside the app when you click on a button.

sorry i got lost.

upload a simple example and describe your issue step by step so we can help you.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
seems the zip is too big (odd) only 2MB
any ways - here is a link to a very basic and primitive sample project


the target real project ius huge and quite old b4a project so no room to deep modifications
this one is as says a basic & primitive sample to demonstrate my problem

my issues are explained within the code but here they are:

1.
the buttons on the calling view are still active so if i remove the test if the view is visible it is any ways fire again and again redisplaying the dialog view
i would like the dialog view to be on top as modal and prevent any under view from being active

2.
i would like it to perform as dialog so it will return a return code (answer as described in the code) to the next line after calling it so i can use it as msgdialog or confirm dialog

so many thanks to the one that can help me out of this mess
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Just thinking...
Using B4XPages shouldn't solve the problem?
As they are never paused the app would not reopen exactly as it was before receiving a call?
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Just thinking...
Using B4XPages shouldn't solve the problem?
As they are never paused the app would not reopen exactly as it was before receiving a call?
my entire project is b4a basic and primitive
it is a very old project but a great app that has many live users
so it has to stay b4a
in the sample i used kind of mix
so i have a few limitations
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
B4XPages is a B4A feature that I think could help you in your task.
Of course I don't know how complex your app is, so I can't tell you how easy it could be to convert it.
I think it could solve your problem but I can't tell for sure.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
i can't just go now changing such a huge live project with many tens of views - that will not be possible
but the new dialog view is b4x but the problem still there...
 
Upvote 0

ilan

Expert
Licensed User
Longtime User
ok i updated you example.

check all lines that contains: '<<<<<<

i added a panel that has transparent background in zDialog layout and now it will catch all clicks.
i also added a map and store the value when you are in a dialog and if you return to the app when you were in a dialog it will show you a log.
this is just an example on to handle your issue. you will need to figure out the rest by yourself how to implement the concept in your app but it should answer all your questions.

btw after removing unnecessary files it has only 6kb.
 

Attachments

  • zDialogv2.zip
    5.5 KB · Views: 118
Upvote 0

Spavlyuk

Active Member
Licensed User
but the place i was is lost
If I understand correctly, you have to break up your code into subs that can be called from multiple events. For example, you can create a sub that shows the dialog and handles the result. Then you can call the sub from the Click event and from Activity_Resume when needed.
 
Upvote 0
Top