B4J Question Change Focus in Menu

Peter Lewis

Active Member
Licensed User
Longtime User
Hi All

I do not know if I am using the correct method to be able to do this. I have looked around the FAQ's ect and could not find anyone or a tutorial on who to build a program with menu's. I eventually looks at non-related examples and worked out this solution.

My workflow on creating a program is to make new apps, smaller that do specific parts of the final app. It is easirt and faster to test and compile.

Then at the last minute put them all into a single app. The decisions of whether they should be Code or Class Modules still does not make 100% sence to me at the moment. I understand the Code modules are more powerful.

Attached is my attempt of doing such a final program.

The Menu's are in Main and to do the program settings are in cSettings.

I initially loaded the same Designer file in Both and after I saved the settings on the setting screen , I managed to get the setting screen to be hidden, then if I went back and tried to get to the setting screen again , It would not show until I restarted the program.

I have tried now not loading the Layout file in the Code Module and cannot get the Setup screen to hide.

Please look at the code and point me in the right direction.

Thank you
 

Attachments

  • menusys.zip
    105.9 KB · Views: 144

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi!

I am looking at your file but just to clarify

Then at the last minute put them all into a single app. The decisions of whether they should be Code or Class Modules still does not make 100% sence to me at the moment. I understand the Code modules are more powerful.

If you want to have only 1 class running at any time then its good to use Code Module, but if you want several instances of the code running at once, then your choice would be Class Module. For your specific case, yes Code module is the best choice.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Hi!

I am looking at your file but just to clarify



If you want to have only 1 class running at any time then its good to use Code Module, but if you want several instances of the code running at once, then your choice would be Class Module. For your specific case, yes Code module is the best choice.

So if I was re-using subs from multiple Modules then putting those subs as public in a Class would be best
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Peter

Attached you will find an example on how to work with single page.

technically you need to recreate the layout everytime you click on each menu item, to avoid this, sometimes is better to create a new child form of the mainform, but in this specific case i believe this is the best solution.

You do not also need to put the code in a code module, you usually do this to have your code tidy.

when dealing with several layouts, its better to have a child of the mainform.rootPane deal with the changes, so the menu will always be there.

i used a small example on a wait for call for animations, as the unloading and loading the layout was a bit odd.

So if I was re-using subs from multiple Modules then putting those subs as public in a Class would be best

For example, you want to have several forms with the same layout you will use a Class, in this case and because it is loaded in the mainform it would be too dificult if not impossible to manage it with a class.
 

Attachments

  • menuSystem.zip
    175.9 KB · Views: 131
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Peter

Attached you will find an example on how to work with single page.

technically you need to recreate the layout everytime you click on each menu item, to avoid this, sometimes is better to create a new child form of the mainform, but in this specific case i believe this is the best solution.

You do not also need to put the code in a code module, you usually do this to have your code tidy.

when dealing with several layouts, its better to have a child of the mainform.rootPane deal with the changes, so the menu will always be there.

i used a small example on a wait for call for animations, as the unloading and loading the layout was a bit odd.



For example, you want to have several forms with the same layout you will use a Class, in this case and because it is loaded in the mainform it would be too dificult if not impossible to manage it with a class.

I will have a look at it, I have been adding more code modules to it since I uploaded and asked the previous question. and after each module works correctly I go onto the new one.

I added a code module and then after clearing all of the errors , I got this message , which gave me No clue where to look. I deleted the module and did a clean but now it still does the same. So what I am saying is it was working before adding the last module, then it stopped working , so I removed the module and did a CLEAN. but now it still gives the same problem. Any Ideas ? The error log is empty. I will still have to go back and change the settings screen as you suggested. I even tried with Debug on and still no clue where to look. I do not have any parameter called index.

errorscreen.png
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
I am not so sure.

because i am using B4J 5.5 and you are using B4J 5.0, it may have caused an error in the 2 wait for statements i put.
 
Upvote 0
Top