Page 1 of 1

How to deal with wanted delay on a string gadget?

Posted: Mon May 22, 2023 2:11 pm
by jacdelad
Hello,
I don't need code, just an info: Let's say I have a StringGadget which is used for filtering a list. Now, I don't want to update the list on every edited character, but let's say one second after the last change was made. Naturally I would start a timer when something changes (and restart it, if it was already started), then process it after it fires. So far so good (and easy).
But, just out of curiosity, is there a better way to do it? Or some different approach, that's more efficient?

Re: How to deal with wanted dealy on a string gadget?

Posted: Mon May 22, 2023 3:05 pm
by Axolotl
I would probably do it the same way....
1. Start timer with EventType Focus
2. count up counter variable, or reset if EventType Change
3. when count is reached, update the list
4. end timer with EventType LostFocus

maybe a bit different, but probably not more efficient

Waiting inside a thread and then a PostEvent() is probably not much better

Re: How to deal with wanted dealy on a string gadget?

Posted: Mon May 22, 2023 4:39 pm
by Caronte3D
If it's not absolutely essential, I'd rather not overload the system, so I don't do it by time, I just do it when the return button is pressed or when StringGadget losses focus.

Re: How to deal with wanted delay on a string gadget?

Posted: Mon May 22, 2023 5:05 pm
by jacdelad
Thanks you both.

@Caronte3D' Yes, that would be another way to do it. I am just curious about the specific problem I described. Like when showing tooltips, you don't to push a button for that.