Recent

Author Topic: Possible Bug or Known Behavior?  (Read 4108 times)

Aruna

  • Hero Member
  • *****
  • Posts: 787
Possible Bug or Known Behavior?
« on: July 16, 2025, 06:38:49 am »
Hi,

I’m trying to understand why I’m able to change a button’s caption even when it’s disabled.

In the first screenshot, you can see what the application looks like when it first runs. If you type something into the edit box labeled "Type Your Caption Here" and then click the Caption Change button below, the caption of the top button updates as expected.

Next, try typing a new caption, but don’t click the Caption Change button yet. Instead, click the toggle button on the far left — you’ll see that the top button becomes disabled.

Now, if you click the Caption Change button, the caption of the top (disabled) button still updates.

Is this the expected and intended behavior? If so, that’s fine — I can work with it. But if not, what would be the recommended way to handle this? The zip file attached contains the source.

Thank you!

dbannon

  • Hero Member
  • *****
  • Posts: 3667
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Possible Bug or Known Behavior?
« Reply #1 on: July 16, 2025, 07:05:03 am »
Yes, while I have never thought about it, I'd expect to be able to change the caption on a disabled button.

Indeed, it annoys me that you don't get to see the Hint when a button is disabled. It makes sense to me to be able to have a hint that says eg, "button disabled because you have a red tie".

I do like your toggle button !   (in the southern hemisphere, down is on, does it have a property to change that ?)

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Fibonacci

  • Hero Member
  • *****
  • Posts: 788
  • Internal Error Hunter
Re: Possible Bug or Known Behavior?
« Reply #2 on: July 16, 2025, 07:10:57 am »
Disabling a button only prevents user clicks, you can still change its caption or any other property from code. Totally expected. Imho having to re-enable it just to update the caption would be weird and might cause flickering.

cdbc

  • Hero Member
  • *****
  • Posts: 2603
    • http://www.cdbc.dk
Re: Possible Bug or Known Behavior?
« Reply #3 on: July 16, 2025, 08:52:14 am »
Hi
Hmmm... "if btnCool.Enabled then btnCool.Caption:= 'Hot';"  :-X
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Thaddy

  • Hero Member
  • *****
  • Posts: 18729
  • To Europe: simply sell USA bonds: dollar collapses
Re: Possible Bug or Known Behavior?
« Reply #4 on: July 16, 2025, 01:08:39 pm »
else btnCool.Caption:= 'cold';
If Europe sells their USA bonds the USD will collapse. Europe can affort that given average state debts. The USA can't affort that. Just an advice...

Aruna

  • Hero Member
  • *****
  • Posts: 787
Re: Possible Bug or Known Behavior?
« Reply #5 on: July 16, 2025, 01:42:53 pm »
Yes, while I have never thought about it, I'd expect to be able to change the caption on a disabled button.
Oh-kay good enough for me!

Indeed, it annoys me that you don't get to see the Hint when a button is disabled. It makes sense to me to be able to have a hint that says eg, "button disabled because you have a red tie".
I suppose we could always test first to see if the button is enabled and if not enabled display that status in a label or whatever works for the user?

I do like your toggle button !   (in the southern hemisphere, down is on, does it have a property to change that ?)
Yes, that property is known as 'aruna' and jokes aside I was in a hurry Davo I did not want to spend too much time putting together a custom component ( Which I will when I find the time to do so) soo.. I fired up my Gimp, grabbed a toggle switch I found on the internet and played with image->transform->flip vertical and took a bit of fiddling to get the two images to line up perfectly in the Timage and that was what I did. The attached screenshots I hope will make you laugh and when I get the time I will put this into a custom component and send your way?

Aruna

  • Hero Member
  • *****
  • Posts: 787
Re: Possible Bug or Known Behavior?
« Reply #6 on: July 16, 2025, 02:05:52 pm »
Hi
Hmmm... "if btnCool.Enabled then btnCool.Caption:= 'Hot';"  :-X
Regards Benny
Hi Benny, whats'up?  So you like it? I will see what I can do with the caption   (I am still waiting for that blue cheese to show up at my door step. Last I checked it was going for $7 bucks which to me is kindda pricey 🤐)
« Last Edit: July 16, 2025, 02:20:23 pm by Aruna »

Aruna

  • Hero Member
  • *****
  • Posts: 787
Re: Possible Bug or Known Behavior?
« Reply #7 on: July 16, 2025, 02:08:03 pm »
else btnCool.Caption:= 'cold';
Hi @Thaddy am going to start writing code in all caps if you guys don't stop with the teasing  %)

Aruna

  • Hero Member
  • *****
  • Posts: 787
Re: Possible Bug or Known Behavior?
« Reply #8 on: July 16, 2025, 02:17:54 pm »
@Davo, the screenshot shows the code...

Aruna

  • Hero Member
  • *****
  • Posts: 787
Re: Possible Bug or Known Behavior?
« Reply #9 on: July 16, 2025, 02:48:41 pm »
Disabling a button only prevents user clicks, you can still change its caption or any other property from code. Totally expected. Imho having to re-enable it just to update the caption would be weird and might cause flickering.
Thank you @Fibonacci so disabling will prevent any interaction but keep status updates such as caption alive? 

dbannon

  • Hero Member
  • *****
  • Posts: 3667
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Possible Bug or Known Behavior?
« Reply #10 on: July 17, 2025, 01:12:22 pm »
@Davo, the screenshot shows the code...

Cute. A very practicable way to do i !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Aruna

  • Hero Member
  • *****
  • Posts: 787
Re: Possible Bug or Known Behavior?
« Reply #11 on: July 17, 2025, 02:53:49 pm »
@Davo, the screenshot shows the code...

Cute. A very practicable way to do i !

Davo
I've attached the ZIP file for your toggle switch—enjoy! I'm nearly done customizing the component for the same toggle, just fine-tuning a few things. I’ll send it your way shortly. if the images do not load give it the full path and things should work. Keep me posted ..  :)


Joanna

  • Hero Member
  • *****
  • Posts: 1415
Re: Possible Bug or Known Behavior?
« Reply #12 on: July 18, 2025, 02:26:20 am »
You can override the set caption method for button to check if it’s enabled
« Last Edit: July 18, 2025, 02:30:54 am by Joanna »

Aruna

  • Hero Member
  • *****
  • Posts: 787
Re: Possible Bug or Known Behavior?
« Reply #13 on: July 18, 2025, 04:38:01 am »
You can override the set caption method for button to check if it’s enabled
Hi Joanna, Would you mind demonstrating how to do this with a small code example? I have a general idea, but a snippet would really help clarify things. Thanks in advance!

Aruna

  • Hero Member
  • *****
  • Posts: 787
Re: Possible Bug or Known Behavior?
« Reply #14 on: July 18, 2025, 05:19:48 pm »
I do like your toggle button !   (in the southern hemisphere, down is on, does it have a property to change that ?)
Davo
Davo, The attached ZIP archive contains a custom toggle switch control. This component provides two main properties:
  • IsOn – indicates the current state of the switch (on or off).
  • SouthernHemisphere – flips the On/Off labels vertically (top-to-bottom and vice versa).
To try it out, unzip the archive and open the Lazarus IDE. From the top menu, go to Package → Open Package File (.lpk)..., select switch.lpk, and install the package. Once installed and activated, you’ll see a new tab labeled Aruna in the component palette, containing a single toggle switch icon. Drop it onto a form to test it out.

A screenshot is attached to show how it looks in the IDE.

You won’t believe some of the things I learned while getting this to work!

 

TinyPortal © 2005-2018