welu1805 Active Member Licensed User Longtime User Dec 29, 2015 #1 Hi all, on my main activity I want to press a button, than should come a window with input fields (edittext). This window should be modal. How can I programm this on principle? Thanks Lutz
Hi all, on my main activity I want to press a button, than should come a window with input fields (edittext). This window should be modal. How can I programm this on principle? Thanks Lutz
JonPM Well-Known Member Licensed User Longtime User Dec 29, 2015 #2 There are a number of input dialogs to choose from. You can use the search feature to find a library that you like. Upvote 0
There are a number of input dialogs to choose from. You can use the search feature to find a library that you like.
welu1805 Active Member Licensed User Longtime User Dec 29, 2015 #3 Yes, I know DialogView. But I would program by myself but don't know how to so. Upvote 0
JonPM Well-Known Member Licensed User Longtime User Dec 29, 2015 #5 What help do you need exactly? Making the popup modal? Place a panel behind it with a click sub and return true Upvote 0
What help do you need exactly? Making the popup modal? Place a panel behind it with a click sub and return true
welu1805 Active Member Licensed User Longtime User Dec 30, 2015 #6 Thank you JonPM, that was my problem. How to catch the click event of the panel. Now it works. Return True is not nessecary because pnlScreen_Click has no ReturnValue. One small problem is still: If I press the Back-key I expect that only the modal dialog will be closed but the app closes. Upvote 0
Thank you JonPM, that was my problem. How to catch the click event of the panel. Now it works. Return True is not nessecary because pnlScreen_Click has no ReturnValue. One small problem is still: If I press the Back-key I expect that only the modal dialog will be closed but the app closes.
klaus Expert Licensed User Longtime User Dec 30, 2015 #7 You need to manage this in the Activity_KeyPress event, something like this: Code: Copy Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK If PanelX.Visible = True Then PanelX.Visible = False Return True Else Return False End If End If End Sub Upvote 0
You need to manage this in the Activity_KeyPress event, something like this: Code: Copy Sub Activity_KeyPress (KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK If PanelX.Visible = True Then PanelX.Visible = False Return True Else Return False End If End If End Sub
welu1805 Active Member Licensed User Longtime User Dec 30, 2015 #8 Thank you Klaus, this is the solution. Upvote 0
welu1805 Active Member Licensed User Longtime User Dec 31, 2015 #9 I want to create an own class for the dialog. Is it possible to trap the Activity_KeyPress event within this class? Upvote 0
I want to create an own class for the dialog. Is it possible to trap the Activity_KeyPress event within this class?
klaus Expert Licensed User Longtime User Dec 31, 2015 #10 No you can't. I suggest you to add a Visible property to your class and check and handle this property in the Activity_KeyPress event routine. Upvote 0
No you can't. I suggest you to add a Visible property to your class and check and handle this property in the Activity_KeyPress event routine.
welu1805 Active Member Licensed User Longtime User Jan 2, 2016 #12 Hi all, best wishes for the new your! Now I tested the library "DialogView". If I call a simple modal dialog with the folloing code Dialog.LoadLayout("dialog1").ShowYesNo("Login", "yes", "no") a modal dialog window appears. After pressing the back key THIS DIAOLG is closed and not the app. Because it runs in debug mode I can see that there is no new activity. Therefore it MUST be possible to trap the back key in the Dialog class in the library. How does it work? Upvote 0
Hi all, best wishes for the new your! Now I tested the library "DialogView". If I call a simple modal dialog with the folloing code Dialog.LoadLayout("dialog1").ShowYesNo("Login", "yes", "no") a modal dialog window appears. After pressing the back key THIS DIAOLG is closed and not the app. Because it runs in debug mode I can see that there is no new activity. Therefore it MUST be possible to trap the back key in the Dialog class in the library. How does it work?
klaus Expert Licensed User Longtime User Jan 2, 2016 #13 I think that DialogView is written with Eclipse not as a B4A class compiled to a library. Upvote 0
welu1805 Active Member Licensed User Longtime User Jan 3, 2016 #14 I found a solution which also works within a class: In the class is a panel for the background of the dialog called "pnlBackground" Further there is a Sub "Show" which sets pnlBackground.Visible = True. I added this code after "pnlBackground.Visible = True": Dim r As Reflector r.Target = pnlBackground r.SetOnKeyListener("OnKeyPress") r.RunMethod2("setFocusable", "True", "java.lang.boolean") r.RunMethod2("setFocusableInTouchMode", "True", "java.lang.boolean") pnlBackground.RequestFocus This is the Sub "OnKeyPress": Sub OnKeyPress(ViewTag As Object, KeyCode As Int, KeyEvent As Object) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If pnlBackground.Visible Then pnlBackground.Visible = False Return(True) Else Return(False) End If Else Return(False) End If End Sub Now the back key closes only the dialog. Upvote 0
I found a solution which also works within a class: In the class is a panel for the background of the dialog called "pnlBackground" Further there is a Sub "Show" which sets pnlBackground.Visible = True. I added this code after "pnlBackground.Visible = True": Dim r As Reflector r.Target = pnlBackground r.SetOnKeyListener("OnKeyPress") r.RunMethod2("setFocusable", "True", "java.lang.boolean") r.RunMethod2("setFocusableInTouchMode", "True", "java.lang.boolean") pnlBackground.RequestFocus This is the Sub "OnKeyPress": Sub OnKeyPress(ViewTag As Object, KeyCode As Int, KeyEvent As Object) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If pnlBackground.Visible Then pnlBackground.Visible = False Return(True) Else Return(False) End If Else Return(False) End If End Sub Now the back key closes only the dialog.
klaus Expert Licensed User Longtime User Jan 3, 2016 #15 You should use the Code: Copy Tags when you post code. [ATTACH=full]40231[/ATTACH] Attachments upload_2016-1-3_15-43-40.png 18.8 KB · Views: 252 Upvote 0
welu1805 Active Member Licensed User Longtime User Jan 4, 2016 #16 This is #14 again with formatted code: I found a solution which also works within a class: In the class is a panel for the background of the dialog called "pnlBackground" Further there is a Sub "Show" which sets pnlBackground.Visible = True. I added this code after "pnlBackground.Visible = True": Code: Copy Dim r As Reflector r.Target = pnlBackground r.SetOnKeyListener("OnKeyPress") r.RunMethod2("setFocusable", "True", "java.lang.boolean") r.RunMethod2("setFocusableInTouchMode", "True", "java.lang.boolean") pnlBackground.RequestFocus This is the Sub "OnKeyPress": Code: Copy Sub OnKeyPress(ViewTag As Object, KeyCode As Int, KeyEvent As Object) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If pnlBackground.Visible Then pnlBackground.Visible = False Return(True) Else Return(False) End If Else Return(False) End If End Sub Now the back key closes only the dialog. Upvote 0
This is #14 again with formatted code: I found a solution which also works within a class: In the class is a panel for the background of the dialog called "pnlBackground" Further there is a Sub "Show" which sets pnlBackground.Visible = True. I added this code after "pnlBackground.Visible = True": Code: Copy Dim r As Reflector r.Target = pnlBackground r.SetOnKeyListener("OnKeyPress") r.RunMethod2("setFocusable", "True", "java.lang.boolean") r.RunMethod2("setFocusableInTouchMode", "True", "java.lang.boolean") pnlBackground.RequestFocus This is the Sub "OnKeyPress": Code: Copy Sub OnKeyPress(ViewTag As Object, KeyCode As Int, KeyEvent As Object) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then If pnlBackground.Visible Then pnlBackground.Visible = False Return(True) Else Return(False) End If Else Return(False) End If End Sub Now the back key closes only the dialog.