Wish Generate DIMs in designer

ac9ts

Active Member
Licensed User
Longtime User
It would be nice to have an option similar to Generate Members in Designer where it would add the DIMs for the views to the Globals section of the code. For example, if I had a label named lblTop in the designer, it would add:

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    ' Main screen views
    Dim lblTop As Label

End Sub
 

ac9ts

Active Member
Licensed User
Longtime User
For example, I have a generic layout that has 5 buttons (btnB1, btnB2, etc.) and a label (lblTop). Using Generate Members, I can selectively add the empty subs for the various views (btnB1_Click, btnB2_Click, etc.)

Now, if I want to add a text label to the button, I would have to add the "Dim btnB1 as Button" line to Sub Globals before I can modify anything with the button.

The example I gave is simple but if you have 20-30 views in a layout and you want to be able to modify the views in code, you need to dimension all the views in the Activity.

What I am asking for is the ability to have the designer add all the view Dim statements to Sub Globals the way Generate Members adds the callback subs. Select "Generate Dims" and a list of all the views is displayed. Tick the checkbox next to any that you would like to have dimensioned and the Designer will add the correct Dim statement to Sub Globals.

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
   
    ' Main screen views
    Dim lblTop As Label   ' <<<<---- I would like it to add this
 

klaus

Expert
Licensed User
Longtime User
This already exists !!!

upload_2016-6-30_19-49-19.png


Check the views you want to be Dimed!

When you right click on a view you get a popup menu where you can define what you want !

upload_2016-6-30_19-51-23.png


Beginner's Guide chapters:
8.4.1 Generate Members
8.8.3.11 Generate
 

Attachments

  • upload_2016-6-30_19-48-56.png
    upload_2016-6-30_19-48-56.png
    10 KB · Views: 152
Last edited:

ac9ts

Active Member
Licensed User
Longtime User
Well shut my mouth! Is this a recent addition? I've used the Generate Members (though sparingly) in the past but do not remember the views being dimed as well. :oops:
 

ac9ts

Active Member
Licensed User
Longtime User
Well, then to save the embarrassment, how about and option to just add the dimension statements as not all views may require a callback? i.e. Generate Members generates the callback sub and adds the Dim statement. Generate Dims just adds the Dim statement.
 

corwin42

Expert
Licensed User
Longtime User
You should have a closer look at the designer again. All features you requested here are available in the designer for years.In Tools->Generate Members you can select what you want to generate.
If you right click on a view you can generate the DIM... or a single event.
 
Top