Alessandro71 Well-Known Member Licensed User Longtime User Dec 26, 2020 #1 How can I can get the B4XPage object which a CustomView belongs to, from inside a CustomView sub. Maybe from mBase itself?
How can I can get the B4XPage object which a CustomView belongs to, from inside a CustomView sub. Maybe from mBase itself?
LucaMs Expert Licensed User Longtime User Dec 26, 2020 #2 Alessandro71 said: Maybe from mBase itself? Click to expand... I think you can get only the Root of the page, using Dim ParentRoot As B4xView = mBase.Parent Upvote 0
Alessandro71 said: Maybe from mBase itself? Click to expand... I think you can get only the Root of the page, using Dim ParentRoot As B4xView = mBase.Parent
Erel B4X founder Staff member Licensed User Longtime User Dec 27, 2020 #3 You can use this code to get B4XPageInfo from a view. You do need to pass mBase for custom views, as this is the real view. Code: Copy Public Sub GetPageInfoFromView(view As B4XView) As B4XPageInfo Dim pi As B4XPageInfo = Null Do While view.IsInitialized And pi = Null pi = B4XPages.GetManager.GetPageInfoFromRoot(view) view = view.Parent Loop Return pi End Sub Last edited: Dec 27, 2020 Upvote 0
You can use this code to get B4XPageInfo from a view. You do need to pass mBase for custom views, as this is the real view. Code: Copy Public Sub GetPageInfoFromView(view As B4XView) As B4XPageInfo Dim pi As B4XPageInfo = Null Do While view.IsInitialized And pi = Null pi = B4XPages.GetManager.GetPageInfoFromRoot(view) view = view.Parent Loop Return pi End Sub
LucaMs Expert Licensed User Longtime User Dec 27, 2020 #4 Erel said: You can use this code to get B4XPageInfo from a view. You do need to pass mBase for custom views, as this is the real view. Click to expand... But then what can you do with it? You can only get a generic object, without having access to its properties and methods. Upvote 0
Erel said: You can use this code to get B4XPageInfo from a view. You do need to pass mBase for custom views, as this is the real view. Click to expand... But then what can you do with it? You can only get a generic object, without having access to its properties and methods.
Erel B4X founder Staff member Licensed User Longtime User Dec 27, 2020 #5 You should cast it to the correct type: Code: Copy Dim pg As MyPage187 = pi.B4XPage Upvote 0
LucaMs Expert Licensed User Longtime User Dec 27, 2020 #6 Erel said: You should cast it to the correct type: Code: Copy Dim pg As MyPage187 = pi.B4XPage Click to expand... Yes but @Alessandro71 doesn't know what it is Upvote 0
Erel said: You should cast it to the correct type: Code: Copy Dim pg As MyPage187 = pi.B4XPage Click to expand... Yes but @Alessandro71 doesn't know what it is
Erel B4X founder Staff member Licensed User Longtime User Dec 27, 2020 #7 The OP wanted to get the B4XPage object. This is the answer. Maybe he wants to raise an event? Code: Copy CallSubDelayed(pi.B4XPage, "NonStandardEventAsWeDontKnowTheEventName") Upvote 0
The OP wanted to get the B4XPage object. This is the answer. Maybe he wants to raise an event? Code: Copy CallSubDelayed(pi.B4XPage, "NonStandardEventAsWeDontKnowTheEventName")
Alessandro71 Well-Known Member Licensed User Longtime User Dec 27, 2020 #8 this was actually for the Initialize of the Camera object for B4i in a cross-platform project B4X: Copy Dim p As B4XPageInfo = B4XUtils.GetPageInfoFromView(mBase) Private Camera As Camera Camera.Initialize("Camera", B4XPages.GetNativeParent(p.B4XPage)) Upvote 0
this was actually for the Initialize of the Camera object for B4i in a cross-platform project B4X: Copy Dim p As B4XPageInfo = B4XUtils.GetPageInfoFromView(mBase) Private Camera As Camera Camera.Initialize("Camera", B4XPages.GetNativeParent(p.B4XPage))
Alessandro71 Well-Known Member Licensed User Longtime User Dec 27, 2020 #9 Erel said: Code: Copy Public Sub GetPageInfoFromView(view As B4XView) As B4XPageInfo Do While True Dim pi As B4XPageInfo = B4XPages.GetManager.GetPageInfoFromRoot(view) If pi <> Null Then Return pi Else view = view.Parent End If Loop Return Null End Sub Click to expand... the above code, which I put in a code module, while no errors are displayed in the IDE, produces the following message in the compilation phase: Compiling generated Java code. Error B4A line: 123 view = view.Parent src\com\project\check\pro\test\b4xutils.java:69: error: unreachable statement ; ^ Upvote 0
Erel said: Code: Copy Public Sub GetPageInfoFromView(view As B4XView) As B4XPageInfo Do While True Dim pi As B4XPageInfo = B4XPages.GetManager.GetPageInfoFromRoot(view) If pi <> Null Then Return pi Else view = view.Parent End If Loop Return Null End Sub Click to expand... the above code, which I put in a code module, while no errors are displayed in the IDE, produces the following message in the compilation phase: Compiling generated Java code. Error B4A line: 123 view = view.Parent src\com\project\check\pro\test\b4xutils.java:69: error: unreachable statement ; ^
Erel B4X founder Staff member Licensed User Longtime User Dec 27, 2020 #10 I've updated the code. It should fix it. Upvote 0
LucaMs Expert Licensed User Longtime User Dec 27, 2020 #11 Erel said: The OP wanted to Click to expand... O.T. I know by "OP" you mean who opened the thread but what does OP stand for? (Just out of curiosity since I prefer to mention the nickname directly, it's much friendlier) EDIT: OP = Original Poster https://it.wikipedia.org/wiki/Espressioni_del_gergo_di_Internet Like this one: Last edited: Dec 27, 2020 Upvote 0
Erel said: The OP wanted to Click to expand... O.T. I know by "OP" you mean who opened the thread but what does OP stand for? (Just out of curiosity since I prefer to mention the nickname directly, it's much friendlier) EDIT: OP = Original Poster https://it.wikipedia.org/wiki/Espressioni_del_gergo_di_Internet Like this one: