Recent

Author Topic: TrackBar is calling OnChange between user and software changes.  (Read 398 times)

jamie

  • Hero Member
  • *****
  • Posts: 6128
TrackBar is calling OnChange between user and software changes.
« on: November 19, 2022, 06:25:59 pm »
I know that I can nullify the event handler, but I don't think that should be done, its just bad patch coding.
 
 Way back I ported an app from Delphi over to here and it has a few TrackBar's in it. I had to put in a hack to determine if the user or software was changing the value.

 Apparently, my old Delphi Install does not call the OnChange handler when software setting the value via Position, for example.

 I don't have my latest Delphi in front of me at the moment, can someone verify if Current Delphi ignores the event when software setting the value?

 In any case, if it is desirable to keep the OnChange event operating always then maybe we should have a MODIFIED property in there that can be tested while in that event? Cleared when software modifieds it, SET otherwise if user changes the value, like a few other controls that have it now.

 The Modified flag is nice because If wanted to reset the value to something different while in the OnChange handler I can test the MODIFIED value which may actually cause a re-entry to the Event. That test can abort before doing damage.


 Waiting for comments.
The only true wisdom is knowing you know nothing

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: TrackBar is calling OnChange between user and software changes.
« Reply #1 on: November 19, 2022, 10:19:50 pm »
I've been working on something that had a /lot/ of software updates between components, and used a non-zero tag to inhibit event loops. There were definitely situations where I wanted a "changed" event to fire, but I definitely had to inhibit overenthusiastic propagation.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jamie

  • Hero Member
  • *****
  • Posts: 6128
Re: TrackBar is calling OnChange between user and software changes.
« Reply #2 on: November 19, 2022, 10:30:28 pm »
 What I am suggesting does not cancel the event, it will still get called but there will be a flag in there as a MODIFIED property where it can be tested to know how the event got there. FALSE = Software change TRUE for User moving the slider.

 Currently I had to place the hack in there because it will causing destructive damage to my setup files for updating items because a change at one slider meant that I had to change a few other things, too!

 This idea does not change any current state of the control, it just adds to its quality.

 Maybe If I have time, I can wedge a property in there and submit it.

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018