I would like to generate my window controls contents from another application (mainly a database editor)
I noticed that when you copy a xojo window control you get an ‘RBCT’ item in the clipboard
so I would like to generate such ‘RBCT’ from my App to paste it in the xojo window editor.
is there any documentation on this xojo internal format or do I have to figure it out myself …?
Deliberately not documented & subject to change
You’d be better off to generate XML or VCP files & then import those as those two formats are very human readable
I’ve personally posted code that can already generate XML projects some 10+ years ago
you cannot export or import a window control alone (or in my case a container control) : the command is greyed.
I’m not generating classes or modules, but only one container control to copy-paste in the window ide
so I must figure out the RBCT format to do that ?
you can use the code I pointed to to write out a single container control class that could be added to a project and then an instance added to a layout
the binary formats that are used on the clipboards are not documented nor would I expect they ever will be
the parameters of the container control are in the instance, the container class is the same for all in all windows.
in every instance, I write the tables, fields involved. would be difficult in a class.
if you’re generating a lot of code that is mostly the same except for a handful of parameters or property names/control names you’re probably working too hard
it’s not a lot of code, it’s a lot of properties with values of tables and fields of the databases
and as I don’t use the databasequery controls, I need something to write the table/fields names without error.
I generate views for the tables with one containercontrol, and must fill the properties in it.
As I edit all my database in a program I made (with Xojo …) I thought about copying the CC with my datas and paste it into the IDE
Can you not rename the controls from within your xojo program, inside an open event?
yes, I could also generate code that I would place in the open event to fill the properties …
I find generating the CC from another App more elegant. but if I do not succeed may be I can use your idea.
A compromise solution is to use your CC generating app to create and export a dataset in text or other convenient format that you can then stick into your main app along with a bit of looping code to apply it to your controls.
I’m attempting the same thing as we already have frameworks with self-registering controls and I also want to generate UI components in our data dictionary app and paste directly into pages and dialogs…if I suss it out I’ll share
OK it looks (can be deceiving) pretty straight forward - I dislike not being able to do things even if they are undocumented and I really would like to accomplish this for our own projects.
if you’re on a Mac there’s a very handy tool here that can help you disassemble the clipboard content…so should be able to roll your own (like most clippy things and our project and form generators you can probably also leave out all but your explicit stuff and have the class completed during the paste process…let you know how I get on with a minimalist button as an example)
OK - here’s a general approach that works for me (on Mac) - and no XML required but you will need MBS Mac plugin.
This example: takes a normal Xojo button, copy to clipboard (type is RBCT), save that clipboard data to binary file, copy to normal text clipboard, paste into a constant, then use as required by replacing specific content with your field names etc, create a new clipboard entry and paste into your designer window…easy really :-).
Step by step:
Create a template of your UI component (in this case it’s just a normal old Xojo button) on a form with whatever settings etc you want/need - you’d normally work with your own button or control subclass that has the extra bits you’ve added like field names etc
Copy it (Cmd+C)
Use the handy tool (link provided above) to save the clipboard to a binary file (you could just add a RBCT save option in your data dictionary app to bypass this - or even create a simple text copy of the RBCT data ready to paste into a constant…just saying what I did that worked for me). I saved a file called ~/tmp/button.clip
To copy the binary button data into the normal clipboard: in a terminal session, cd ~/tmp, cat button.clip | pbcopy
create a constant in your data dictionary project to hold the button template (e.g. kButton and paste in the clipboard contents) - it’s OK with all the binary values - just don’t try editing it as you’ll probably break the data as it’s in the correct format already.
Add some code behind a button etc to generate a button as RBCT data:
dim c as new ClipboardMBS
// create a copy of the constant to s and replace any stuff that needs replacing (e.g. s=kButton.replace("~fieldname", "table.name") etc.)
- Paste your new button into your window, page dialog etc
You may need to tweak code to suit, and there are lots of other ways to streamline this process but it should give you enough to go on. I think I’ll combine steps 3 and 4 into my dictionary app so I don’t have to muck about, or might create the templates as a resource file in the app folder so I can replace them as I need without recompiling…whatever suits really.
Hope that helps.
why do you need the mbs plugin ? clipboard class can do what you explain with clipboardmbs.
anyway nice explaination, I was arrived at almost the same conclusion.
clipboard viewer is a nice tool for that.
In addition to RBCT for controls theres CbCI for Window, Class, Module, ContainerControl, Interface, Menubar… top level components, and RSCI for Event Handler, Method, Property, Structure… class parts, CbMt for multiple top level components, RSCI is used also for multiple class parts.
Clipboard Viewer reveals those codes but once in hand Xojo can pull (and push) the data.
[code]dim c As new Clipboard
if c.RawDataAvailable(“RSCI”) then
dim m As MemoryBlock = c.RawData(“RSCI”)
//store or process data
elseif //try another code
Thing is if you select a Class and Method then copy, Clipboard Viewer shows both a CbCI and RSCI but Xojos Clipboard object will only see 1 of them.
The format appears to be the same as for a binary project, which is easy to interpret. I’ll throw it at my project viewer later to see what happens
You could also script Arbed, which is able to read that binary format, to have it convert it to XML
for the records, this is what I did.
drop the window control you want to generate on a window, copy it, use clipboardviewer to save the RBCT item.
then use BBEdit or textwrangler to open it, copy all and paste in a constant in Xojo (this paste also the control characters)
then made a small method to replace the main fields you want to replace, I put some known values **1 **2 … in them before copying.
and well it works nice ! I select my database items in my app, ctrl-clic generate my window controls the way I want
paste them in a xojo window, all fields are correctly named, the window controls are named too.
HUGE time saver for me, and (almost) typing error free system.
I can generate quite complex database screens in seconds.
have a good day.