[Gambas-user] [Gambas-devel] Creating a Control

Tobias Boege taboege at ...626...
Mon Sep 8 14:34:45 CEST 2014


On Mon, 08 Sep 2014, John Leake wrote:
> Hi All,
> 
> Many thanks for your responses.  I am posting this in the devel list
> because I am prepared to spend the time improving the IDE.
> 

Yes, but you only see 3 - 4 people regularly on gambas-devel (and mainly
through gambas-devel-svn when they do commits), as opposed to at least 10
on gambas-user. In the difference are people like Bruce Bruen who earns a
living programming in Gambas and doing such things.

> So for directions I go to http://www.gambasdoc.org/help/dev/gambas?v3
> 
> Lets say I just want to create a ToggleButton of my own that is
> unchanged from that which exists already Except for the name of course.
> 
> Start
> -----
> 1) create a new project and set its project type to 'Graphical
> application' and check the option 'Component programming'.
> 

No, you are not programming a component here. A component is a shared
library which you can plug into the interpreter to add functionality.
You don't do that here (yet?), you're just experimenting in an ordinary
project, not a component project.

This decision isn't messing things up. Components written in Gambas are
just a superset of ordinary projects (IIRC?). But you shouldn't include
the additional meta data if you don't need to.

> 2) Select the parent directory (my work is in ~/dev/Gambas3).
> 
> 3) Give the project a name and title of 'MyToggleButton'.
> 
> 4) Drop a toggle button onto 'FTest' and run. All good so far.
> 
> The docs say:-
> 
> "Only the _IsControl and the _Properties constants are mandatory."
> 
> and
> 
> "These hidden constants are inherited like any other constant. So you
> don't have to actually declare them in each control, as soon as there is
> some inheritance relationships between them. "
> 
> So there is not much more to do since I do not want to change any
> behaviour or control properties.  Just get the control to show up in the
> control toolbox and allow users to design with it just like the original
> ToggleButton.
> 
> 5) From the docs "Each control must have an icon that will be displayed
> in the IDE control tool box.".  I was hoping that I would inherit these
> also. There are already two png files in
> '~/dev/gambas3/MyToggleButton/.hidden/control' so I change the images so
> I can distinguish them from the originals.
> 
> The docs say "The IDE can make binary packages of your component, as it
> does for any other normal projects." so
> 
> 6)  Project/Make/Executable - good no errors.
> 

Very good so far.

> 7) Close and save the project and create a new one that should show
> 'MyToggleButton' in the 'Form/Controls' tab but alas it is not there !
> 
> End
> ---
> 
> This may be a naive point of view but shouldn?t it just work like this if ?
> 

It's very natural that it is not there: your MyToggleButton is a class in
your first project. That's why the IDE can read it and add it to the
Controls tab. If you open another project without this class, the class...
cannot be found. Your custom controls are local to your project, so to say.

If you want to use it in other projects, you can
 - create a component, install it and plug it in (Project -> Properties ->
   Components),
 - create a so-called library [0] or
 - copy your classes over or create symlinks to them.

Regards,
Tobi

[0] http://gambaswiki.org/wiki/doc/library

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list