Recent

Author Topic: TTabControl setting TabIndex doesn't fire OnChange in 1.8.2 but did in 1.6.x  (Read 4058 times)

FRex

  • New Member
  • *
  • Posts: 20
I've upgraded from some 1.6.x to freshest Lazarus 1.8.2 and my program which previously worked is now buggy due to the fact that OnChange is not fired when TabIndex property is assigned to.

It really threw me off, the documentation doesn't mention it and I was testing program on a fresh Linux install and downloaded the most recent Lazarus (1.8.2) and first thought it's a mismatch between LCL on Gtk2 and Win32 (and was going to ask about that before thinking to check my program after upgrading to the same version on my main Windows machine first).

Is this a bug/regression or is this the new intended behavior?

To get the same behavior as in 1.6.2 should I rewrite these parts of the code to instead check if TabIndex did get changed (in case the OnChanging event sets allow to False) and then do what I'd do in the OnChange event?
App to keep track of notes in a single plain text file tagged by hashtags: https://github.com/FRex/botes


FRex

  • New Member
  • *
  • Posts: 20
Thanks for that. I will update my program to fit that.

But should the OnChanging event be happening then?

I still get it via a programmaticall change but the Delphi Tokyo docs seem to say neither should happen:
http://docwiki.embarcadero.com/Libraries/Tokyo/en/Vcl.ComCtrls.TCustomTabControl.OnChanging
http://docwiki.embarcadero.com/Libraries/Tokyo/en/Vcl.ComCtrls.TCustomTabControl.OnChange

Excuse me if I'm wrong. I'm not a Delphi programmer at all, it was the first language I learned in high school before C and C++ took over so I have the basics but I never used it seriously and I'm bad at Free/Object Pascal, I just use it for fun on one personal tool.
App to keep track of notes in a single plain text file tagged by hashtags: https://github.com/FRex/botes

jamie

  • Hero Member
  • *****
  • Posts: 6091
any event that gets triggered via user interaction  should not in reality be getting triggered via code changing..

This causes lots of issues.

 In code you can selectively call the same event code directly if you feel you must have the ONCHANAGE event code
to be executed...

 Most of those events are those that get triggered via user actions and code execution should not be automatically calling it

I am glad they did this for the TabControl, I hope they do this for a few others that have no way to know who the event
got called.

 There are some that I've see that have a flag to report as to how it get called, "User" which indicates that the event got
called via a user CLICK or what ever.

 At some point you'll understand why this is important..

 anyways, as for the TabControl, in the options, there is a flag you can set to that it will call the OnChange when you
directly change the Tabindex via code instead of User.

 But in all reality , you do this code so that means you can also call the OnChange event directly via code if you whish..

 TabIndex := ??????
if Assigned(OnChange) then OnChange(Sender);
The only true wisdom is knowing you know nothing

FRex

  • New Member
  • *
  • Posts: 20
Yes, I get and agree with the logic of that in Delphi and LCL trying to be compatible with it but then why does OnChanging get triggered by code?
App to keep track of notes in a single plain text file tagged by hashtags: https://github.com/FRex/botes

jamie

  • Hero Member
  • *****
  • Posts: 6091
Hmm, when changing properties via code the OnChange Event will get called for a TtabCOntrol if the OPTIONS is set for it..

Its not suppose to get called and it was fixed but for those that have code working with it the old way, you can set the
flag in the OPTIONS to make the Onchange event get called when your code make changes to the control that reflects the
TAB index.

  Normally USER changes should only be triggering this event "OnChange" for the TTabControl.

 I Think before 1.8.2 it would trigger the OnChange in both cases, user and code changes but then a flag was added to
fix that..

If I understood your question I believe I have answered, if not, please ask again differently :)
The only true wisdom is knowing you know nothing

FRex

  • New Member
  • *
  • Posts: 20
I'm asking why OnChanging still works the old way, not OnChange. In Delphi Tokyo docwiki both are said to not trigger from code but in LCL right now by default one does and the other doesn't.
App to keep track of notes in a single plain text file tagged by hashtags: https://github.com/FRex/botes

wp

  • Hero Member
  • *****
  • Posts: 11858
I guess it is just forgotten. Please write a bug report.

jamie

  • Hero Member
  • *****
  • Posts: 6091
I don't understand?

I updated a program the other day that uses the TtabControl , it was last compiled with 1.6.4 I think and now
1.8.2, 

 The first thing I had to do was fix the TAB change events because when I changed The TABIndex the Onchange
did NOT get called..

 I elected to call it via code instead of setting the flag but it does work as it should, I don't know what you are doing
otherwise, this is a 32 bit app.

 SVN 57369

Check yours please.

EDIT:

 Please look at the Subject Line...
 "TTabControl setting TabIndex doesn't fire OnChange in 1.8.2 but did in 1.6.x"

 Reading this you are confusing the issue, it clearly states what I have been saying, but you are now saying the
opposite..

 Please clarify what you really mean..

« Last Edit: May 08, 2018, 01:00:03 am by jamie »
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018