iOS Question creating a view on panel in a code module

yo3ggx

Active Member
Licensed User
Longtime User
Hi all,

I have successfully used B4A for several years and now I intend to port some o my applications to iOS.
I'm trying to put some shared code in a code module. Some of the functions from the code module are used to create views on some panels. Let's say that in the main module I call the function from the code module to put a button with specific settings on a panel. This works as expected.
Now in the main module I create the button event routine.
Sub AButton_Click
... some code
End sub
When I click on that button nothing happen, but if I move the event routine in the code module, it works.
It seems that the event sub must be located in the same module where the view is added to the panel.
This is a normal behavior?

Thank you,
Dan
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is a normal behavior?
Yes. Static code modules in B4i and B4J are more powerful than in B4A. In B4A static code modules cannot handle events, so the events are raised on the "parent" activity or service.

The best way to solve it is by using classes instead of code modules. This way the events will be raised in the class modules and it will behave the same in B4A and the other platforms.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…