On Sun, 07 Sep 2014, John Leake wrote: > Hi All, > I am struggling to understand how to create a new control. > > Please forgive me, I have read the help on this but I am none the wiser. > > As a test I just want to create a control that behaves like a > ToggleButton but changes colour each time it is clicked. > > Could anyone help me get started ? >
Hui, I don't know how simple you think this is but depending on from where you want to start, it can require quite some code (involving drawing every part of your control if you want to write it from scratch). Of course, you can, on the other side, start with a ToggleButton and add just the colour plays to it which would require significantly less code. It depends on how much control you need to have. There are different approaches (hard ~ more control): - inherit ToggleButton [0] (easy), - inherit UserControl [1] (harder, chosen often in Gambas sources), - create a Form and put your things together [2] (less applicable here but useful to remember when you want to create compound controls) (also easy). You may also want to integrate the control into the IDE's Form editor [3]. I tried to put example classes together for the above approaches but you are way better off subscribing to the gambas-user mailing list (you are still on gambas-devel here which is for discussion about contributions to Gambas, not questions about programming in it). Some people there have done this sort of thing way more often than me. See the SF info page [4]. Regards, Tobi General advice: if you have a slight idea already of what to search for, it is a very good idea to look at the Gambas source code. Lots of things you use as a Gambas programmer are implemented in Gambas itself. [0] http://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/comp/src/gb.form/.src/MessageLabel.class or have a look at http://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/comp/src/gb.form/.src/TagBox/TagComboBox.class for an example of a very lazy coder :-) [1] http://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/comp/src/gb.form/.src/Spinner.class This is actually a pretty good example! [2] http://sourceforge.net/p/gambas/code/HEAD/tree/gambas/trunk/comp/src/gb.form/.src/FInputBox.class Plus the other *InputBox.{form,class} files in that directory. [3] http://gambaswiki.org/wiki/dev/gambas [4] https://lists.sourceforge.net/lists/listinfo/gambas-user -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user