iOS Question Action event (click) occurs in module of Addview not current screen

Dan Harding

Member
Licensed User
Longtime User
On Android if I pass the address of a panel and then use it to add a view, the click event for that view occurs in the activity where the panel was loaded.

On iPhone, it appears to occurs in the module where the call to Addview was made.

I am attempting to use common logic to create these controls in a scrollview, but have the event happen back outside my common logic. Any suggestions on how to make this work?
 

Dan Harding

Member
Licensed User
Longtime User
Two sample projects. One for Android, one for iOS. The click event happens in Main on Android and in Module1 on iOS. I have put click events in both modules in both projects and placed breakpoints in all 4 places. The breakpoint happens in different places on Android and iOS.
 

Attachments

  • DemoAndroid.zip
    491 KB · Views: 268
  • DemoiOS.zip
    81.3 KB · Views: 246
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I will explain the difference. The views events are raised in the module that initialized the view.

However in B4A, due to the way Android works, static code modules cannot handle events as they don't have a "context" of their own. They use the context of the calling module (the main activity in this case).

You should use a class instead of a code module if you want to handle the events in the module in B4A (and it will work in B4i as well).
 
Upvote 0

Dan Harding

Member
Licensed User
Longtime User
Thank you for your prompt replies. I am actually looking for the other way. That the events can occur outside the module they were created.

I would like to make one or more library files with subs being passed a scrollview (or a panel of a scrollview) plus some arrays/maps, etc. to create a custom list of various views. However, since this might be a library or at least a shared module, I don't want the event to happen in the module, as it will be used by multiple projects.

From what you have said, I think the answer is sorry, you can't do that for both Android and iOS, but I wanted to make sure.

Thanks,
Dan
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…