Wish Proposal for Automatic Inclusion of Crucial Functions in B4xPage Project Creation

carlos7000

Well-Known Member
Licensed User
Longtime User
I would like to propose an enhancement for the B4a development environment, specifically aimed at improving the process of creating new B4xpage projects. Currently, when initiating the creation of a new project, the environment automatically generates a series of files that serve as templates, providing the developer with predefined lines of code and functions. This results in a significant time-saving during the development process.

More precisely, the environment generates the "Main" and "B4XPage" files to establish the project's foundation. Within the "B4XPage" file, functions like "Class_Global," "Initialize," and "B4XPage_Created" are generated, which are crucial for the project's functionality.

However, I'd like to highlight an important distinction between B4x and B4A. In the B4A version, the environment generated similar files but also included vital functions like "Activity_Resume" and "Activity_Pause." These two functions were of great importance as they allowed actions to be executed when the application gained or lost focus.

In the case of B4xPages, although these functions can exist, they are not automatically available when creating a new project. This requires the developer to already be aware of them and add them manually afterward. This manual addition process can complicate the transition from B4A to B4x, leading to frustration for the developer and incurring extra costs in terms of time and potentially even money.

In light of this, I propose that these functions, along with other relevant functions that I am currently unaware of and would need to discover gradually, be automatically incorporated into the "B4XMainPage" and each "B4xPage" file upon the creation of a new project. This would ensure that developers have immediate access to these essential functions without having to search for them separately or add them manually.

This enhancement would not only streamline the development process but also ensure that all critical functions are available from the outset, potentially enhancing efficiency and the overall development experience in the B4a environment, making it easier to learn B4a, and reducing the learning curve for B4X.
 

aeric

Expert
Licensed User
Longtime User
"Activity_Resume" and "Activity_Pause."
automatically incorporated into the "B4XMainPage" and each "B4xPage"
I think this functions can only be use inside Main activity of B4A.

It's okay to make a wish but you can do it yourself too. Create a new b4xtemplate (based on the current template) and add this functions into the Main activity.

Edit: "Activity_Resume" and "Activity_Pause" are already inside B4A Main activity template.
 
Last edited:

carlos7000

Well-Known Member
Licensed User
Longtime User
Hi aeric

Although I have been programming in b4a for years, for me and the B4X newbies learning is a long and steep curve, besides that learning B4x causes frustration and a great waste of time. looking for functions similar to Activity_Resumee took me a whole afternoon and several hours the next day. It's a lot of time writing different words, word combinations, publishing posts, etc. Looking for basic things. It is not exaggeration. I am a 50 year old man. The changes for me begin to be difficult. I like B4a and have created many applications with it. When one is so adapted to something, change is not easy. It is not easy. B4x is not difficult. That's what I'm discovering little by little. The problem is finding the information is a long and very frustrating process. The Manual is very concise. And the information that is not in the manual is scattered in hundreds or thousands of posts. For many the manual may be more than enough. But for me and for others it is not. Today I finally found a message from someone talking about the B4XPage_Foreground and B4XPage_Background functions, functions that I was also looking for. I asked him if he knew of any function similar to Activity_Resume and he told me "try B4XPage_Appear".

I understand that people are annoying when they have a problem, all they want is for them to write the complete program or, as we say here, "everything is chewed up." They want everything without any effort. But making it easier to put the basic functions in the newly created file as in b4a reduces frustration a bit, improves productivity, improves efficiency, saves time, decreases the learning curve, reduces frustration and best of all, it stimulates more people to learn. B4x
 

aeric

Expert
Licensed User
Longtime User
Hi Carlos,
I understand your frustration as someone who is familiar with writing B4A from the start, we are used to the default standard, using Activity.
The default template is still supported and not going away anytime. We can still use the "old" way. Add more activities as we like.
But B4XPages solve some problems. This is where we decide to use it instead of the first method.

The only post to read are the following:
https://www.b4x.com/android/forum/t...framework-for-managing-multiple-pages.118901/
https://www.b4x.com/android/forum/threads/b4x-b4xpages-what-exactly-does-it-solve.119078/

Not every project we need all events.
However, if the standard project you want require all these events added, you can create your own template. I created a lot of templates actually (especially in B4J).

Otherwise, the trick is:
In B4XMainPage,
1. Start typing Private Sub and space then press tab.
2. Choose or double-click on B4XPagesManager. You will see all the available events.
3. Choose Disappear for example.


1691904482165.png

4. Replace "EventName" with "B4XPage". Now, you have the new event.

1691904769618.png
->
1691904852724.png


Check post#7 for all the events.
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
However, I'd like to highlight an important distinction between B4x and B4A. In the B4A version, the environment generated similar files but also included vital functions like "Activity_Resume" and "Activity_Pause." These two functions were of great importance as they allowed actions to be executed when the application gained or lost focus.

In the case of B4xPages, although these functions can exist, they are not automatically available when creating a new project. This requires the developer to already be aware of them and add them manually afterward. This manual addition process can complicate the transition from B4A to B4x, leading to frustration for the developer and incurring extra costs in terms of time and potentially even money.
There is nothing special with the B4XPages project template. Anyone can create templates: [B4X] Projects Templates
You can easily extend the template as you like and share it :)
But if you create a new B4XPage (class) it doesn't contain the skeletons of all the events available for the page.

You could create your own templates, not just B4XPages, but any class or code module, and add them to the project via the menu: Project - Add existing modules.
This functionality could be improved if you had the ability to set up your own path to save your module templates.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
But if you create a new B4XPage (class) it doesn't contain the skeletons of all the events available for the page.
This is also solvable. You can create a b4xlib or jar with the custom class templates. Unzip B4XPages.b4xlib and check manifest.txt + b4xpage.b4x_excluded
 

carlos7000

Well-Known Member
Licensed User
Longtime User
Hi Carlos,
I understand your frustration as someone who is familiar with writing B4A from the start, we are used to the default standard, using Activity.
The default template is still supported and not going away anytime. We can still use the "old" way. Add more activities as we like.
But B4XPages solve some problems. This is where we decide to use it instead of the first method.

The only post to read are the following:
https://www.b4x.com/android/forum/t...framework-for-managing-multiple-pages.118901/
https://www.b4x.com/android/forum/threads/b4x-b4xpages-what-exactly-does-it-solve.119078/

Not every project we need all events.
However, if the standard project you want require all these events added, you can create your own template. I created a lot of templates actually (especially in B4J).

Otherwise, the trick is:
In B4XMainPage,
1. Start typing Private Sub and space then press tab.
2. Choose or double-click on B4XPagesManager. You will see all the available events.
3. Choose Disappear for example.


View attachment 144717
4. Replace "EventName" with "B4XPage". Now, you have the new event.

View attachment 144719 -> View attachment 144720

Check post#7 for all the events.

Hello.
I had already seen the Bx4 Manager but I didn't see that through it I had access to the functions I was looking for.

Thank you so much
 

PaulMeuris

Active Member
Licensed User
You can also find this information in the booklet: B4XPages Cross-platform projects page 16.
You can use Google Translate to get a copy in Spanish. Select the PDF document and you can get a Spanish version.
 

aeric

Expert
Licensed User
Longtime User
Last edited:

aeric

Expert
Licensed User
Longtime User
I'm not sure if I understood correctly. I'll see if I can do it
B4xtemplate is just a zip file but the file extension .zip is renamed as .b4xtemplate.

You can use any unzip tools such as WinZip or WinRAR to unzip the files.

The files are same as B4X project except you can rename the project.b4a or project.b4j to $APPNAME$.b4a or $APPNAME$.b4j so when you create a new project, the project file has the name you enter in the new project dialog.
 

aeric

Expert
Licensed User
Longtime User
Is this what you want?

1692086130562.png


1692086014769.png


manifest.txt:
Version=1.11
B4J.DependsOn=B4XCollections, JavaObject, jXUI
B4A.DependsOn=B4XCollections, XUI, JavaObject
B4i.DependsOn=B4XCollections, iXUI
CustomClassTemplates=B4XPage|b4xpage,MyB4XPage|myb4xpage
 

Attachments

  • MyB4XPages.b4xlib
    7.6 KB · Views: 54
Top