Page 1 of 1

[SOLVED] Knowing When Text Changed

Posted: Sun Aug 03, 2025 9:11 pm
by Randy Walker
How does NotePad or any other app know if text was changed? Even as little as one character, it always seems to know.

Re: Knowing When Text Changed

Posted: Sun Aug 03, 2025 9:33 pm
by infratec

Re: Knowing When Text Changed

Posted: Sun Aug 03, 2025 10:11 pm
by Randy Walker
Wow! Thanks infratec. So much more complex than I imagined.

Re: [SOLVED] Knowing When Text Changed

Posted: Mon Aug 04, 2025 12:15 am
by BarryG
For your own apps, you can use #PB_EventType_Change for some gadgets to know when they've changed, or use GetGadgetText() and compare it with a previous GetGadgetText() to see if the text differs.

To detect changes in third-party apps like Notepad, you'd need to parse its window to get all its "gadgets" and then check the one with the "Edit" class (similar to what I said about GetGadgetText() above).

Re: [SOLVED] Knowing When Text Changed

Posted: Mon Aug 04, 2025 1:09 pm
by Axolotl
Even if the post is marked as solved.
For completeness, there are also the API functions under Windows that can upgrade an EditorGadget() ....
A small extract to answer the above question:

Code: Select all

; query the EditorGadget for modified text since last reset
;
Macro EditorGadget_IsModified(Gadget) 
  SendMessage_(GadgetID(Gadget), #EM_GETMODIFY, #Null, #Null) 
EndMacro

; reset EditorGadget modify flag 
;
Macro EditorGadget_ResetModified(Gadget) 
  SendMessage_(GadgetID(Gadget), #EM_SETMODIFY, #False, #Null)
EndMacro

Re: [SOLVED] Knowing When Text Changed

Posted: Mon Aug 04, 2025 7:48 pm
by Randy Walker
Thanks Axolotl... And looks so much simpler too.

Re: [SOLVED] Knowing When Text Changed

Posted: Mon Aug 04, 2025 7:59 pm
by Randy Walker
BarryG wrote: Mon Aug 04, 2025 12:15 am For your own apps, you can use #PB_EventType_Change for some gadgets to know when they've changed...
Hadn't considered it might be detected by EventType() so that's a really great tip!!
or use GetGadgetText() and compare it with a previous GetGadgetText() to see if the text differs.
Well yeah that's the obvious way, but bothersome.
To detect changes in third-party apps like Notepad, you'd need to parse its window to get all its "gadgets" and then check the one with the "Edit" class (similar to what I said about GetGadgetText() above).
Good info, but way outside of my interest. just wanted to know about changes to editor and string gadgets.
THANKS BarryG!!!

Re: [SOLVED] Knowing When Text Changed

Posted: Mon Aug 04, 2025 10:56 pm
by BarryG
Was detecting the change for your own app, or for third-party apps? Because you only mentioned Notepad (third-party).

Re: [SOLVED] Knowing When Text Changed

Posted: Mon Aug 04, 2025 11:21 pm
by Randy Walker
BarryG wrote: Mon Aug 04, 2025 10:56 pm Was detecting the change for your own app, or for third-party apps? Because you only mentioned Notepad (third-party).
Was thinking of my own app and using NotePad as an example of an app that exhibits that feature. Sorry for confusion and not being more explicit.