TickBox a custom CheckBox

So you have written that new, must have program. Let us see it here.
User avatar
BruceSteers
Posts: 478
Joined: Thursday 23rd July 2020 5:20pm

TickBox a custom CheckBox

Post by BruceSteers » Sunday 28th February 2021 3:55pm

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
snap.png (299.79 KiB) Viewed 806 times
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
Attachments
TickBox.zip
Updated again
(27.79 KiB) Downloaded 33 times
Last edited by BruceSteers on Monday 01st March 2021 4:59pm, edited 2 times in total.
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
BruceSteers
Posts: 478
Joined: Thursday 23rd July 2020 5:20pm

Re: TickBox a custom CheckBox

Post by BruceSteers » Sunday 28th February 2021 4:06pm

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


Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
PJBlack
Posts: 132
Joined: Tuesday 09th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: TickBox a custom CheckBox

Post by PJBlack » Sunday 28th February 2021 4:18pm

TickBox.class 66 MakeLabel(): .Centered is not a property

User avatar
BruceSteers
Posts: 478
Joined: Thursday 23rd July 2020 5:20pm

Re: TickBox a custom CheckBox

Post by BruceSteers » Sunday 28th February 2021 4:46pm

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...
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
Quincunxian
Posts: 113
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: TickBox a custom CheckBox

Post by Quincunxian » 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.
Cheers - Quin.
I code therefore I am

User avatar
BruceSteers
Posts: 478
Joined: Thursday 23rd July 2020 5:20pm

Re: TickBox a custom CheckBox

Post by BruceSteers » Monday 01st March 2021 5:00pm

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 :)
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
BruceSteers
Posts: 478
Joined: Thursday 23rd July 2020 5:20pm

Re: TickBox a custom CheckBox

Post by BruceSteers » Monday 01st March 2021 5:13pm

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
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
PJBlack
Posts: 132
Joined: Tuesday 09th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: TickBox a custom CheckBox

Post by PJBlack » Monday 01st March 2021 11:08pm

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 759 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: 478
Joined: Thursday 23rd July 2020 5:20pm

Re: TickBox a custom CheckBox

Post by BruceSteers » Tuesday 02nd March 2021 5:03pm

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 :)
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
PJBlack
Posts: 132
Joined: Tuesday 09th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: TickBox a custom CheckBox

Post by PJBlack » Tuesday 02nd March 2021 5:18pm

BruceSteers wrote:
Tuesday 02nd March 2021 5:03pm
i'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