[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scrolling/keeping textArea down


Il 24/09/25 16:26, Lee ha scritto:
On 9/24/25 9:39 AM, Lee wrote:
On 9/24/25 8:17 AM, Gianluigi wrote:
OK, the example was too simple, this new one that I attach, here works with both gtk and qt.

Unfortunately, it does not work correctly here with GTK3.

I don't have an issue with the Enter key adding text twice, so I commented out TextBox1.Clear for my convenience. The relevant code for reference:
[code]
Public Sub Button1_Click()

   TextArea1.Text &= "\n\n" & TextBox1.Text
   ' TextBox1.Clear
   Wait 0.3
   TextArea1.EnsureVisible

End
[/code]

Interestingly, it does work as expected in some instances (described below) with Wait 0.3, Wait 0.1, and Wait. But, with Wait 0, the behavior of the scroll bar is immediately random.

If the mouse cursor remains over the TextArea (control) and the Enter key is used to add text, it works as expected.

But, if the mouse has entered the control and then leaves the control to click Button1, the newly added text is not displayed until the mouse re-enters the control. There is one exception to this.

If when the mouse has entered the control, the scroll bar is scrolled by dragging it and then the mouse leaves the control to click Button1, it works as expected.


It is a weird bug indeed.

I think I have found a workaround:
[code]
Public Sub Button1_Click()

   TextArea1.Text &= "\n\n" & TextBox1.Text
   ' TextBox1.Clear
   Wait ' or Wait 0.1
   TextArea1.SetFocus ' <--- THIS
   TextArea1.EnsureVisible

End
[/code]



I tested it on a VM with Debian 13 LXDE and Gambas3 Stable installed, compiled as per these instructions:
https://www.gambas-it.org/wiki/index.php/Compilare_Gambas
my new code works well, and so does yours.
Unfortunately, if you use the QT libraries and don't include "TextBox1.Clear," the text is duplicated with both Cinnamon and LXDE.

[System]
Gambas=3.20.4 ab0099a (stable)
OperatingSystem=Linux
Distribution=Debian GNU/Linux 13 (trixie)
Kernel=6.12.48+deb13-amd64
Architecture=x86_64
Cores=4
Memory=3921M
Language=it_IT.UTF-8
Platform=x11
Desktop=LXDE
DesktopResolution=96
DesktopScale=7
WidgetTheme=clearlooks
Font=Sans,10
DarkTheme=False


Follow-Ups:
Re: Scrolling/keeping textArea downGianluigi <gradobag@xxxxxxxxxxx>
References:
Scrolling/keeping textArea downBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Scrolling/keeping textArea downBenoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: Scrolling/keeping textArea downGianluigi <gradobag@xxxxxxxxxxx>
Re: Scrolling/keeping textArea downLee <t.lee.davidson@xxxxxxxxx>
Re: Scrolling/keeping textArea downLee <t.lee.davidson@xxxxxxxxx>