TickBox a custom CheckBox

Post your must have Gambas Components/Controls/Classes/Modules here.
Post Reply
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

TickBox a custom CheckBox

Post by BruceSteers »

I present the TickBox

Have spent ages on this blooming thing.
It's not the easiest thing to make a custom checkbox control.
well making it was pretty straight forward but then getting it to look how a normal checkbox looks on gtk2+3 and QT took days of tweaking and experimenting/testing.

How it is different...

TickBox1.TextPosition = Align.Left ' put the text to the left not the right.

TickBox1.Picture = picture ' use ANY image you want as the check mark (default is the stock "apply" image)

TickBox1.BoxBackground = ColorInteger ' set the background colour of the checkbox

Box/check image size will grow to font height

Here it is alongside some normal checkbox's
snap.png
It still needs a tweak or 2 with spacing n stuff and on QT if you resize the form they all jump left a pixel or 2 for some reason but it seems harmless.
And when the text is to the right the box seems too far left, no padding and a bit of a gap between the box and the text, i'll work on it.

Have fun
Last edited by BruceSteers on Monday 1st March 2021 4:59pm, edited 2 times in total.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: TickBox a custom CheckBox

Post by BruceSteers »

here it is in action , i have it on a test ap next to some std checkbox's i click a few things and hit tab a few times


If at first you don't succeed , try doing something differently.
BruceS
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: TickBox a custom CheckBox

Post by PJBlack »

TickBox.class 66 MakeLabel(): .Centered is not a property
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: TickBox a custom CheckBox

Post by BruceSteers »

PJBlack wrote: Sunday 28th February 2021 4:18pm TickBox.class 66 MakeLabel(): .Centered is not a property
Doh bugger it's not backward compatible :oops:

i forgot to test it on other gambas versions sorry :(

that's a quick fix by putting "Try" before the .Centered command on line 70
Try .Centered = True

but it might mess up the layout on older gambas and i'll have to do it manually,

thanks for letting me know.
I'll update the above file...
If at first you don't succeed , try doing something differently.
BruceS
User avatar
Quincunxian
Posts: 171
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: TickBox a custom CheckBox

Post by Quincunxian »

I did this a while ago with a scrollview and child checkboxes as I missed the checked list box of vb.net.
Wrote a class to do all the grunt work and it worked perfectly but in the end, I found that a multi select list box does the same thing
for much less work. I can point it at a data table and a reference table that has boolean values and it just works.
I'm a more pedestrian programmer. I write things that I need to do practical stuff and not 'tinker under the hood' too much.

Nice to see what the tinkerers are up to though.
Cheers - Quin.
I code therefore I am
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: TickBox a custom CheckBox

Post by BruceSteers »

Quincunxian wrote: Sunday 28th February 2021 10:30pm I did this a while ago with a scrollview and child checkboxes as I missed the checked list box of vb.net.
Wrote a class to do all the grunt work and it worked perfectly but in the end, I found that a multi select list box does the same thing
for much less work. I can point it at a data table and a reference table that has boolean values and it just works.
I'm a more pedestrian programmer. I write things that I need to do practical stuff and not 'tinker under the hood' too much.

Nice to see what the tinkerers are up to though.
sounds cool :)

I've almost tinkered this into perfection now :)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: TickBox a custom CheckBox

Post by BruceSteers »

I just re-uploaded the zip (above in first post) after doing some tests on debian 10 gambas 3.12

seems okay now.

only issues are...
is it does not quite operate AutoResize like gtk does on gambas 3.12 but does on 3.15

and the box has a position glitch it qt on gambas 3.15 not 3.12 where it's a little too far right then jumps into correct position on window resize.


and i was so close to perfection ;) :lol:

BruceS
If at first you don't succeed , try doing something differently.
BruceS
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: TickBox a custom CheckBox

Post by PJBlack »

hey bruce ... be true ... you're waiting for my post didn't you?
Bildschirmfoto_2021-03-01_23-46-38.png
Bildschirmfoto_2021-03-01_23-46-38.png (56.09 KiB) Viewed 12196 times
left is GTK and right is QT5 ... different look different behavior ... call me old shool but qt right panel is what i aspect to get ...

i found one or two (besides the jumping qt labels) very little unbeautiful missbehaviour ... the original check box will change background on mouseenter and restore on mouseleave ... on mouse down the checkbox is highlighted and the checkmark is set and on mouseup the highlight is unset ... your checkbox will not highlight background on mouseenter/leave and will not set checkmark on mousedown but on mouseup ... and the labeltext is highlighted (again call me old shool ...) but is forgotten to unset on mouseleave/lostfocus ...

you can call me "Korinthenkacker" (dict.leo.org says: inch pincher or nitpicker/nit-picker) :D

btw. love your progs
User avatar
BruceSteers
Posts: 1521
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: TickBox a custom CheckBox

Post by BruceSteers »

Getting it to look like the others do is like playing the Vulcan game of Kal-toh, i'll make one small change that will make it all perfectly fall into place ;)

I may just have to state , well it's not the gtk checkbox or the qt checkbox , it's the tickbox :)
If at first you don't succeed , try doing something differently.
BruceS
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: TickBox a custom CheckBox

Post by PJBlack »

BruceSteers wrote: Tuesday 2nd March 2021 5:03pmi'll make one small change that will make it all perfectly fall into place ;)
congratulations ... if i make a small change everything turns into deepest dysfunctional bullshit ... so ... usercontrol development is pure fun and soooo easy they said ...
Post Reply