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

Discussion in 'iOS Questions' started by Dan Harding, Jun 15, 2015.

  1. Dan Harding

    Dan Harding Member Licensed 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?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    The events in both B4A and B4i happen in the module that initialized the view (or where the layout was loaded).
     
  3. Dan Harding

    Dan Harding Member Licensed 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.
     

    Attached Files:

  4. Erel

    Erel Administrator Staff Member Licensed 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).
     
  5. Dan Harding

    Dan Harding Member Licensed 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
     
Loading...