Main Board > Nomads

using code snippets for standard control definitions

(1/2) > >>

Thomas Bock:
This is how we create new controls with default definitions in nomads. We use Sublime 3.2, which is able of using code snippets. (In PSPad they are called clips.) These snippets are like macros plus some predefined replacement tokens. Upon execution of a snippet each replacement token can be substituted on the fly. The result is a text fragment, designed to speed up coding. We use this feature to create controls with several default values in nomads.


* create a properly defined control in nomads and copy it to the clipboard

* paste the clipboard content into an editor and make changes in order to save it as a code snippet (depending on the editor)
This may start like this (keep the empty lines and everything else)
[Nomads]
PANEL       2537${1:<CONTROL>}
36
24
20
1
M


19

P";"+id$+"_POST_CREATE"

P";"+id$+"_ON_CHANGE"

...

* use such a code snippet and copy the whole text result to the clipboard
the editor will ask for a substitution for ${1:<CONTROL>}
* move to a panel and paste the control
That's a little bit long-winded, but it works and it is much faster than editing all the entrypoints one by one.

Stéphane Devouard:
Thanks Thomas !

Stéphane Devouard:
Just looked at Visual Studio Code
The syntax for the placeholders replacement when inserting the snippet is the same

Nice one, Thomas. Thx again.

Mike King:
Thomas,

If you are wanting to copy/insert consistent controls why not use the lookup button beside the control name when defining the control in Nomads?

This will bring up a list of similar type/named controls from every other panel in the current library.

For example if you want consistent "Exit" buttons, all you need to do is select the type of control and position to the upper left corner where you want it placed.  When the control definition panel/property list appears press the query button in the name field and the system will show all similar controls with the same name.  You can disable the name match if desired and just select a similar control.  Basically this does a direct copy without the clipboard.

Have a look at the attached image.  If you press the lookup button (circled in green), the system will take the control name from the definition, send it to the lookup where if the match name option is enabled the system will find all similarly named objects in the same library.  You can search other libraries if desired and search by control type instead of name.

Does this do what you are looking for?
You should be able to create a template panel with all the common controls you may need.

Also consider using the Visual Classes and Templates to help assure consistency in your controls.

Thomas Bock:
Mike,

I wasn't aware of this feature. I did dsome tests. It is okay for small libraries due to the time needed for the search. And  it is integrated of course.
But using the clipboard I can insert a group of controls at once as long as an embedded panel is no option.

Navigation

[0] Message Index

[#] Next page

Go to full version