Android Question [B4XPages] - using PreferenceDialog

udg

Expert
Licensed User
Longtime User
Hi all,

I'd like some detailed info about the workings of the whole Delegates stuff (to heighten my general knowledge).

Then I'd like to understand how to use correctly the PreferenceDialog in a secondary B4xPage.
Among the requirements for a PreferenceDialog there's an Activity_KeyPress sub (that check prefdialog.BackKeyPressed), IME management and a macro to insert in the Manifest relating to Main.
I would use B4XPage_CloseRequest like below:
B4X:
Private Sub B4XPage_CloseRequest As ResumableSub
    If prefdialog.BackKeyPressed Then Return False
    Return True
End Sub
This should limit the closing to the dialog (if it's open) remaining on the B4XPage. Otherwise (there's no dialog showing) close the page.

But what if the KeyCode to intercept is not the KEYCODE_BACK? What code should be in place on the page to react appropriately?

udg
 

udg

Expert
Licensed User
Longtime User
Hi Erel, thank you for your reply.
The main reason for my post is that I'd like to understand how it works the "delegation", in general.

From your post#2 I get that when we need to work on an event inside a B4xPage, we raise the event in Main and write the corresponding sub only on those pages that need to work on that event.

BTW, is it ok how I arranged for the Back key in my post#1? I verified that it works like I described, but a confirmation is always welcomed.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
From your post#2 I get that when we need to work on an event inside a B4xPage, we raise the event in Main and write the corresponding sub only on those pages that need to work on that event.
That's true for activity events.

BTW, is it ok how I arranged for the Back key in my post#1?
Looks correct.
 
Upvote 0
Top