EditorGadget clearing bug
- marcoagpinto
- Addict
- Posts: 1045
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
EditorGadget clearing bug
Heya,
If I write a ton of text into an editor gadget and then scroll down to the bottom, the scroll bar moves along.
If I then press a button which I created to remove all the text, the scroll bar continues as it was.
The scroll bar should disappear if I do a SETGADGETTEXT(#EDITORGADGET,"").
If I write a ton of text into an editor gadget and then scroll down to the bottom, the scroll bar moves along.
If I then press a button which I created to remove all the text, the scroll bar continues as it was.
The scroll bar should disappear if I do a SETGADGETTEXT(#EDITORGADGET,"").
Re: [PB6.03b2] EditorGadget clearing bug
It disappears here when I do that. You need to post a runnable snippet to show the problem you're getting.marcoagpinto wrote: Wed Jul 05, 2023 12:45 pmThe scroll bar should disappear if I do a SETGADGETTEXT(#EDITORGADGET,"").
- marcoagpinto
- Addict
- Posts: 1045
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: [PB6.03b2] EditorGadget clearing bug
@BarryGBarryG wrote: Wed Jul 05, 2023 10:16 pmIt disappears here when I do that. You need to post a runnable snippet to show the problem you're getting.marcoagpinto wrote: Wed Jul 05, 2023 12:45 pmThe scroll bar should disappear if I do a SETGADGETTEXT(#EDITORGADGET,"").
You can reproduce it with this code (remember to scroll down to the bottom before pressing the CLEAR button).
NOTICE: for the bug to happen, you can't click inside the editor gadget, use ONLY THE SCROLL BAR TO SCROLL TO THE BOTTOM.
Code: Select all
Enumeration 1
#EDITOR_BATTLE_DESCRIPTION
#IMAGE_BATTLE_DESCRIPTION_TRASHCAN
#TEXT_BATTLE_DESCRIPTION_NUMBER_CHRS
EndEnumeration
OpenWindow(0,0,0,800,600,"Test",#PB_Window_SystemMenu|#PB_Window_WindowCentered)
x=10
y=10
w=600
EditorGadget(#EDITOR_BATTLE_DESCRIPTION,x,y,w,200+200,#PB_Editor_WordWrap)
t$="Scroll to the button and press the CLEAR button!!!! Test Test Test"+#LF$
For f=1 To 10
t$+t$
Next f
SetGadgetText(#EDITOR_BATTLE_DESCRIPTION,t$)
y=GadgetY(#EDITOR_BATTLE_DESCRIPTION)+GadgetHeight(#EDITOR_BATTLE_DESCRIPTION)+10
TextGadget(#TEXT_BATTLE_DESCRIPTION_NUMBER_CHRS,x,y,200,24,"Characters:"+Str(Len(GetGadgetText(#EDITOR_BATTLE_DESCRIPTION))))
y+24+10
ButtonGadget(#IMAGE_BATTLE_DESCRIPTION_TRASHCAN,x,y,90,24,"Clear")
Repeat
event=WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
; Clear the editor gadget
Case #IMAGE_BATTLE_DESCRIPTION_TRASHCAN
SetGadgetText(#EDITOR_BATTLE_DESCRIPTION,"")
t$="Characters:"+Str(Len(GetGadgetText(#EDITOR_BATTLE_DESCRIPTION)))
If GetGadgetText(#TEXT_BATTLE_DESCRIPTION_NUMBER_CHRS)<>t$
SetGadgetText(#TEXT_BATTLE_DESCRIPTION_NUMBER_CHRS,t$)
EndIf
EndSelect
EndSelect
Until okay=#True
QUICK EDIT2: Sometimes it happens, other time it doesn't. Please try a few times.
Re: [PB6.03b2] EditorGadget clearing bug
Tried it over and over and it always removes the scroll bar here. Using v6.03 beta 1 (x64). Can anyone else confirm?marcoagpinto wrote: Wed Jul 05, 2023 10:38 pmYou can reproduce it with this code (remember to scroll down to the bottom before pressing the CLEAR button)
- marcoagpinto
- Addict
- Posts: 1045
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: [PB6.03b2] EditorGadget clearing bug
Well, from now on, I will place YouTube videos of bugs happening.
Here it is the video of it happening:
https://www.youtube.com/watch?v=4QYZ2VUHSA0
Here it is the video of it happening:
https://www.youtube.com/watch?v=4QYZ2VUHSA0
Re: [PB6.03b2] EditorGadget clearing bug
Videos are not always necessary, and it wasn't that I didn't believe you. What version of PureBasic are you using?
Here's an animated gif of what it does for me:

Here's an animated gif of what it does for me:

- marcoagpinto
- Addict
- Posts: 1045
- Joined: Sun Mar 10, 2013 3:01 pm
- Location: Portugal
- Contact:
Re: [PB6.03b2] EditorGadget clearing bug
Heya,
As the topic of the post mentions:
PB 6.03 beta 2 x64.
Windows 10 x64.
But notice that the bug doesn't continually happen, so there must some sort of thing happening that only now and then triggers the issue.
As the topic of the post mentions:
PB 6.03 beta 2 x64.
Windows 10 x64.
But notice that the bug doesn't continually happen, so there must some sort of thing happening that only now and then triggers the issue.
Re: [PB6.03b2] EditorGadget clearing bug
I just tried it with the same version as you, and no bug here. I don't know why.
Last edited by BarryG on Thu Jul 06, 2023 11:02 am, edited 1 time in total.
Re: [PB6.03b2] EditorGadget clearing bug
I can see it here as well, not everytime but it happens. I will take a look
Re: [PB6.03b2] EditorGadget clearing bug
I think that the EditorGadget needed to be refreshed after SetGadgetText()
Try
Try
Code: Select all
Case #IMAGE_BATTLE_DESCRIPTION_TRASHCAN
SetGadgetText(#EDITOR_BATTLE_DESCRIPTION,"")
HideGadget(#EDITOR_BATTLE_DESCRIPTION,0)
t$="Characters:"+Str(Len(GetGadgetText(#EDITOR_BATTLE_DESCRIPTION)))
If GetGadgetText(#TEXT_BATTLE_DESCRIPTION_NUMBER_CHRS)<>t$
SetGadgetText(#TEXT_BATTLE_DESCRIPTION_NUMBER_CHRS,t$)
EndIf
Egypt my love
Re: [PB6.03b2] EditorGadget clearing bug
I tried to fix it but it seems like to be a Windows glitch here as we use the standard WM_SETTEXT message to clear the text
Re: [PB6.03b2] EditorGadget clearing bug
This issue is caused by a system global setting. (Animate controls and elements inside windows)
After some experimentation, the most obvious solution to this issue seems to be to intercept the GetThemeTransitionDuration API and return 0 as the time value.
The MS Detours files are in the link in the post below.
https://www.purebasic.fr/english/viewtopic.php?t=83878
After some experimentation, the most obvious solution to this issue seems to be to intercept the GetThemeTransitionDuration API and return 0 as the time value.
The MS Detours files are in the link in the post below.
https://www.purebasic.fr/english/viewtopic.php?t=83878
Code: Select all
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
#Lib_x86x64 = "86"
CompilerElse
#Lib_x86x64 = "64"
CompilerEndIf
Import "detours_x" + #Lib_x86x64 + ".lib"
DetourTransactionBegin.l()
DetourTransactionCommit.l()
DetourUpdateThread.l(hThread)
DetourAttach.l(*ppPointer, pDetour)
DetourDetach.l(*ppPointer, pDetour)
EndImport
Import "uxtheme.lib"
GetThemeTransitionDuration.l(hTheme, iPartId.l, iStateIdFrom.l, iStateIdTo.l, iPropId.l, *pdwDuration.Long)
EndImport
Prototype.l ptGetThemeTransitionDuration(hTheme, iPartId.l, iStateIdFrom.l, iStateIdTo.l, iPropId.l, *pdwDuration.Long)
Global GetThemeTransitionDuration__.ptGetThemeTransitionDuration = @GetThemeTransitionDuration()
#SBP_ARROWBTN = 1
#SBP_THUMBBTNVERT = 3
#TMT_TRANSITIONDURATIONS = 6000
Procedure.l My_GetThemeTransitionDuration(hTheme, iPartId.l, iStateIdFrom.l, iStateIdTo.l, iPropId.l, *pdwDuration.Long)
Debug #PB_Compiler_Procedure
;Debug "" + iPartId + " " + iStateIdFrom + " " + iStateIdTo + " " + iPropId
If iPropId = #TMT_TRANSITIONDURATIONS And (iPartId = #SBP_ARROWBTN Or iPartId = #SBP_THUMBBTNVERT)
*pdwDuration\l = 0
ProcedureReturn #S_OK
EndIf
ProcedureReturn GetThemeTransitionDuration__(hTheme, iPartId.l, iStateIdFrom.l, iStateIdTo.l, iPropId.l, *pdwDuration.Long)
EndProcedure
If DetourTransactionBegin() = #NO_ERROR
If DetourUpdateThread(GetCurrentThread_()) = #NO_ERROR
If GetThemeTransitionDuration__
If DetourAttach(@GetThemeTransitionDuration__, @My_GetThemeTransitionDuration()) <> #NO_ERROR
Debug "Detours Error: GetThemeTransitionDuration"
Else
Debug "GetThemeTransitionDuration OK"
EndIf
EndIf
DetourTransactionCommit()
EndIf
EndIf
Enumeration 1
#EDITOR_BATTLE_DESCRIPTION
#IMAGE_BATTLE_DESCRIPTION_TRASHCAN
#TEXT_BATTLE_DESCRIPTION_NUMBER_CHRS
EndEnumeration
OpenWindow(0,0,0,800,600,"Test",#PB_Window_SystemMenu|#PB_Window_WindowCentered)
x=10
y=10
w=600
EditorGadget(#EDITOR_BATTLE_DESCRIPTION,x,y,w,200+200,#PB_Editor_WordWrap)
t$="Scroll to the button and press the CLEAR button!!!! Test Test Test"+#LF$
For f=1 To 10
t$+t$
Next f
SetGadgetText(#EDITOR_BATTLE_DESCRIPTION,t$)
y=GadgetY(#EDITOR_BATTLE_DESCRIPTION)+GadgetHeight(#EDITOR_BATTLE_DESCRIPTION)+10
TextGadget(#TEXT_BATTLE_DESCRIPTION_NUMBER_CHRS,x,y,200,24,"Characters:"+Str(Len(GetGadgetText(#EDITOR_BATTLE_DESCRIPTION))))
y+24+10
ButtonGadget(#IMAGE_BATTLE_DESCRIPTION_TRASHCAN,x,y,90,24,"Clear")
Repeat
event=WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
; Clear the editor gadget
Case #IMAGE_BATTLE_DESCRIPTION_TRASHCAN
SetGadgetText(#EDITOR_BATTLE_DESCRIPTION,"")
t$="Characters:"+Str(Len(GetGadgetText(#EDITOR_BATTLE_DESCRIPTION)))
If GetGadgetText(#TEXT_BATTLE_DESCRIPTION_NUMBER_CHRS)<>t$
SetGadgetText(#TEXT_BATTLE_DESCRIPTION_NUMBER_CHRS,t$)
EndIf
EndSelect
EndSelect
Until event=#PB_Event_CloseWindow
Re: [PB6.03b2] EditorGadget clearing bug
So it looks like a Windows 'feature'. We won't try to patch such behaviour anymore as it can introduce more unexpected oddities later.