B4J Question When creating custom views, can one add a source code script for #Events and access that?

Mashiane

Expert
Licensed User
Longtime User
Secondly, is it possible when creating custom views to add a code script for an Event? If so, how does one access this too on the code writing area?
Just had a thought of creating an empty sub with the same signature as the event, wrote my code there inside <code></code>. Managed to generate the members and also managed to access the sub code. Perfect.
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
As an example, you are defining your custom view with events, for example

B4X:
#Event: Pdf (item As Map)
#Event: Delete (item As Map)
#Event: Print (item As Map)
#Event: Cancel (item As Map)
#Event: Change (item As Map)
#Event: Download (item As Map)

Then you add your Designer Properties

B4X:
#DesignerProperty: Key: Title, DisplayName: Title, FieldType: String, DefaultValue:  , Description:
#DesignerProperty: Key: AutoID, DisplayName: Auto ID/Name, FieldType: Boolean, DefaultValue: False, Description: Overrides the ID/Name with a random string.
#DesignerProperty: Key: Ref, DisplayName: Ref, FieldType: String, DefaultValue:  , Description:
#DesignerProperty: Key: ItemKey, DisplayName: ItemKey, FieldType: String, DefaultValue:  , Description:
#DesignerProperty: Key: ItemsPerPage, DisplayName: ItemsPerPage, FieldType: String, DefaultValue:  , Description:

Now what I initially wanted to achieve was, when one writes on the B4J ide for example, intellisense picks up the events and can show code.

What I discovered so far is that such events are availble when one goes to Tools > Generate Members

So I thought, if for example, I want to pick up code that I would like the developer to access when a particular event is being coded via the IDE, the best approach was to create an empty procedure with event signature, this will be availble for intellisense, but I can just copy the code I need.

For example, lets assume, that when the Download event is fired for that particular custom view, I want to have some predefined code I could use. So..

A. In the custom view, create an empty sub with the code script that I need to copy at runtime

B4X:
''code to copy when i download
'<code>
'You can copy the code below for the Download Event
'Sub Download (Item As Map)
'Dim a As Int
'Dim x as Int
'a + x = 10
'End Sub
'</code>
Sub Download (Item As Map)  
End Sub

This way you are able to Generate Members for the Event and get the Download Sub via intellisense and I can copy the code script that intellisense shows to inside my event code


Ta!

Well, it would be nice that such functionality could be available without having to define an event and then create an empty sub just to get the code script you'd like to use when coding.

All the best.
 
Last edited:
Upvote 0
Top