Text Colour attributes on Check Boxes

I couldn’t reply to an already posted topic, So…

That “cheat” does work Dave, but there are problems. The normal behavior of a checkbox is that it will 'Action" if either the checkbox OR text itself is selected. This is not particularly vital to my program, but annoying nonetheless and does not conform to POLA (Principle of least astonishment).

So I thought, being the smart person that I am . . . Aha! . . . perhaps I could invoke the mouse down event on the text label to ‘check’ the box. This idea seemed reasonable. Unfortunately when I implemented that Event Handler, the Navigator showed a gray arrow (as it should) but I could not click into it to show the Action/Event. A definite BUG.

I also tried extending the checkbox with the same caption and overlaying white text with that same caption - looked fine in the IDE but the text disappeared when mouse over - utterly absurd!

It’s important to point out that the checkbox was within a colored rectangle (reasonable), which unfortunately seems to have a habit of automatically grouping controls together without my say-so, so perhaps there’s a clue there.

In any case, I was forced to restart the whole IDE. Then the ‘mouse down’ action suddenly appeared where it should have. I was so thrown off (astonished) by this series of events that I no longer trusted what I was looking at, and therefore have reverted back to a previous saved version, lest my hours of coding be lost.

Very stressful.

Surely no “Declares” or any other esoteric methods as put forward (in the original referred thread) are required for this seemly rather simple requirement.

Cheers.

A simple CheckBox1.Value = not (CheckBox1.Value) in the label’s MouseDown event works here.

Thanks Jean-Paul. I’m using Windows, and as far as I can tell MacOS seems to fair better (reliable/expected) in the IDE and also the final results ie. transparency issues etc.

Sure, there are work-arounds - I’ve done that many many times in other programming languages. Sadly these basic issues are still unresolved. I took a break from programming for the last six years, and now back into it somehow thinking that things would be better this time around.

“Canvas, Shmanvas” for all I care. I simply wanted to colour the text on a checkbox, without some convoluted foul and dirty fix.

I’m a Software Developer, not a creator of coding tools - I leave that to others who are much more qualified.

I’ll work out a solution - I always do.

Cheers.

Yes, that would work, and similar to the code I had in mind, but as I pointed out above I couldn’t even access the MouseDown event to implement any code whatsoever. I had to restart the IDE.

That is the point I’m getting at. After this happened I’m very circumspect about the IDE as a whole. I’ve seen a few weird things happen, but not like this. A bit un-nerving.

I can understand that. It used to happen to me with regularity a few major releases ago. 2016R3 seems very stable though. My habit is to close and open Xojo a few times each week. And I try to avoid cross-version development if possible.

Steve, you should go get a beer, a coffee, for a walk, smell the roses. Programming and working around are one and the same thing.

When you come back with a clear eye, the solution will present itself.

Thanks everyone.

Good call Michel, instead of a coffee or beer I decided to get a good nights sleep instead - did me the world of good :slight_smile:

I moved the label outside of the containing rectangle (in case that was causing the problem) and added the MouseDown event handler - the event appeared in the navigator where it should be, then I moved the label back into to rectangle.

I added the code as Tanner suggested, to the MouseDown event and voila!! works perfectly.

[code]chkBoxEnableRecord.Value=Not(chkBoxEnableRecord.Value)

// If chkBoxEnableRecord.Value=True Then
// chkBoxEnableRecord.Value=False
// Else
// chkBoxEnableRecord.Value=True
// End If[/code]

Thanks for that Tanner, you can see my long-winded version in the code - does the same thing but your method is more elegant and efficient.

So I’ve actually learned two things. Don’t stress if the IDE does something unexpected, take a break - then re-start Xojo and try again. The other is the more efficient code method.

Cheers.

:slight_smile: