Recent

Author Topic: TATTabs component update when closing a tab  (Read 614 times)

Mastropiero

  • New Member
  • *
  • Posts: 29
TATTabs component update when closing a tab
« on: March 06, 2025, 12:49:50 pm »
Hi there,

I'm writing an application that uses a TATTabs component and a panel showing data that is updated when a tab is changed (OnTabChanged event).

However, when I close a tab, I can't get the panel updated, since the OnTabChanged event is not triggered (to my understanding it should because after closing a tab, another tab is taking its place, so it's same as if the user clicked on that tab).

I've tried to use the OnTabClose event without success (I can't know what the new tabindex will be, only know the tabindex of tab being closed, so I can update controls properly).

What's the correct way to solve this?

Thank you in advance.

cdbc

  • Hero Member
  • *****
  • Posts: 2206
    • http://www.cdbc.dk
Re: TATTabs component update when closing a tab
« Reply #1 on: March 06, 2025, 12:53:27 pm »
Hi
Every 'TTabSheet' has an 'OnShow' event, just hook into that...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

Mastropiero

  • New Member
  • *
  • Posts: 29
Re: TATTabs component update when closing a tab
« Reply #2 on: March 06, 2025, 01:15:09 pm »
Hi
Every 'TTabSheet' has an 'OnShow' event, just hook into that...
Regards Benny

What is a TTabSheet? I'm not using that.   How does it relate to TATTabs? 

Thank you.

cdbc

  • Hero Member
  • *****
  • Posts: 2206
    • http://www.cdbc.dk
Re: TATTabs component update when closing a tab
« Reply #3 on: March 06, 2025, 01:47:22 pm »
Hi
Sorry, my bad. 'TTabSheet' is the /standard/ page going together with the standard 'TPageControl' in Lazarus...
I just thought, that 'ATTabs' was in some kind of family with them...
I use the standard controls and hook into 'OnShow' per tab and that works flawlessly.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

AlexTP

  • Hero Member
  • *****
  • Posts: 2574
    • UVviewsoft
Re: TATTabs component update when closing a tab
« Reply #4 on: March 06, 2025, 03:16:51 pm »
I don't confirm that TATTabs OnTabChange is not called on tab closing.
it is called for me when I test in the project "apps/demo_tabs".

1. Your ATFlatControls is not too old? Make sure you use last ATFlatControls from Github.
2. Make sure debug info is "drarf 2 with sets" for package ATFlatControls. it was "automatic" until today, which is bad.
3. Open apps/demo_tabs. Open file attabs.pas, place breakpoint in the SetTabIndexEx() and see that it's called on closing of ANY tab, even last.

AlexTP

  • Hero Member
  • *****
  • Posts: 2574
    • UVviewsoft
Re: TATTabs component update when closing a tab
« Reply #5 on: March 06, 2025, 04:42:17 pm »
I reproduced the problem. SetTabIndexEx was not calling FOnTabChanged if we delete the active tab and the same tab index activates.
Must be fixed:
https://github.com/Alexey-T/ATFlatControls/commit/9ff39124b27bf60d551a95bae005cd481b8165c0
« Last Edit: March 06, 2025, 04:43:54 pm by AlexTP »

AlexTP

  • Hero Member
  • *****
  • Posts: 2574
    • UVviewsoft
Re: TATTabs component update when closing a tab
« Reply #6 on: March 06, 2025, 05:24:50 pm »
Now code in SetTabIndexEx is

Code: Pascal  [Select][+][-]
  1.     if not bDisableEvent then
  2.     begin
  3.       if Assigned(FOnTabClick) then
  4.         FOnTabClick(Self);
  5.  
  6.       if Assigned(FOnTabChanged) {and bTabChanged} then //do not test bTabChanged: on closing the active tab, bTabChanged=False
  7.         FOnTabChanged(Self);
  8.     end;

so FOnTabChanged is now the same as FOnTabClick. No other places where FOnTabClick/Changed are called. So now we don't need OnTabChanged and I will remove it.

Mastropiero

  • New Member
  • *
  • Posts: 29
Re: TATTabs component update when closing a tab
« Reply #7 on: March 06, 2025, 05:45:41 pm »
Impressive job, Alexey!!!

This is why I love open-source software.

Thank you for your quick support and fix.

 

TinyPortal © 2005-2018