EditorGadget auto scroll to last line ...
EditorGadget auto scroll to last line ...
Hi,
For the communications with one of my older robots,
I use my terminal program I created in PB 5.73 x64 / win 10.
Works since yesterday, but I have some problem.
For the transmitter and receiver side I use [EditorGadgets]
and this works very well.
Only I need to move my mouse over it and scroll down manually.
Is there a setting to scroll automatically to the EditorGadget last line ?
Thanks,
marc
For the communications with one of my older robots,
I use my terminal program I created in PB 5.73 x64 / win 10.
Works since yesterday, but I have some problem.
For the transmitter and receiver side I use [EditorGadgets]
and this works very well.
Only I need to move my mouse over it and scroll down manually.
Is there a setting to scroll automatically to the EditorGadget last line ?
Thanks,
marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
Re: EditorGadget auto scroll to last line ...
2 possibilities:
1. Add the line in pos 0 and not -1 (order is switched)
2. There was already a solution for your question
viewtopic.php?p=593643#p593643
1. Add the line in pos 0 and not -1 (order is switched)
2. There was already a solution for your question

viewtopic.php?p=593643#p593643
Re: EditorGadget auto scroll to last line ...
Hi infratec,
due to some circumstances in my life,
I didn't touched my old robots for some time now.
Sorry, I forgot I asked this already.
? is this the beginning of "dementia" ?
thanks
marc
due to some circumstances in my life,
I didn't touched my old robots for some time now.
Sorry, I forgot I asked this already.
? is this the beginning of "dementia" ?

thanks
marc
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
-
- Addict
- Posts: 1077
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
Re: EditorGadget auto scroll to last line ...
Hi marc... I've always used sendmessage to do that. Unfortunately not cross platform, but works well enough for me in Windows:marc_256 wrote: Fri Sep 19, 2025 9:25 pm Is there a setting to scroll automatically to the EditorGadget last line ?
Thanks,
marc
Code: Select all
bottom = Len(GetGadgetText(YourGadget))
SendMessage_(GadgetID(YourGadget), #EM_SETSEL, bottom, bottom)
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
Re: EditorGadget auto scroll to last line ...
@Randy, you don't need to calculate the bottom. Just use -1 for wParam and lParam, which means to select the end:
Code: Select all
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 8, 8, 306, 133)
For a = 0 To 100
AddGadgetItem(0, a, "Line "+Str(a))
Next
SendMessage_(GadgetID(0), #EM_SETSEL, -1, -1)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: EditorGadget auto scroll to last line ...
Those who need a cross-platform solution may take a look into my 13 years old code example which demonstrates how to add and select line after line in an EditorGadget and always keep the last line visible.
Collection of cross-platform examples with API functions to extend PureBasic
-
- Addict
- Posts: 1077
- Joined: Sun Jul 25, 2004 4:21 pm
- Location: USoA
Re: EditorGadget auto scroll to last line ...
Even Better yet for this purpose. Important to know though, EM_SETSEL is used to SELect text, with wParam as starting point and lparam as ending point. And when these two values match it places the cursor at that point.BarryG wrote: Sat Sep 20, 2025 4:38 am @Randy, you don't need to calculate the bottom. Just use -1 for wParam and lParam, which means to select the end:
Last edited by Randy Walker on Sat Sep 20, 2025 10:24 pm, edited 1 time in total.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy
I *never* claimed to be a programmer.
Re: EditorGadget auto scroll to last line ...
Hello Shardik !
Thank you for this recall !
Thank you for this recall !
Re: EditorGadget auto scroll to last line ...
Just for fun 
It could be OK with Windows,Mac and Linux
I tested only with Windows

It could be OK with Windows,Mac and Linux
I tested only with Windows
Code: Select all
Procedure SelectItem(gadget)
no = CountGadgetItems(gadget)
AddGadgetItem(gadget,-1,"")
RemoveGadgetItem(gadget, no)
SetActiveGadget(gadget)
EndProcedure
If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(0, 8, 8, 306, 133)
For a = 0 To 100
AddGadgetItem(0, a, "Line "+Str(a))
Next
SelectItem(0)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Egypt my love
- Mindphazer
- Enthusiast
- Posts: 468
- Joined: Mon Sep 10, 2012 10:41 am
- Location: Savoie
Re: EditorGadget auto scroll to last line ...
Hi Rashed,
it doesn't work on MacOS : Last line is indeed selected, but the first line are still displayed...
it doesn't work on MacOS : Last line is indeed selected, but the first line are still displayed...
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
...and unfortunately... Windows at work...
Re: EditorGadget auto scroll to last line ...
Hi Mindphazer
Sorry,I don't have Mac to test
But try the next it may make a difference
Sorry,I don't have Mac to test
But try the next it may make a difference
Code: Select all
Procedure SelectItem(gadget)
SetActiveGadget(gadget)
no = CountGadgetItems(gadget)
AddGadgetItem(gadget,-1,"")
RemoveGadgetItem(gadget, no)
EndProcedure
Egypt my love
Re: EditorGadget auto scroll to last line ...
For windows and acc. to MSDN: WM_VSCROLL message
BTW: This checks whether the last line is visible or not.
Code: Select all
SendMessage_(GadgetID(0), #WM_VSCROLL, #SB_BOTTOM, 0)
Code: Select all
Procedure IsGadgetLastItemVisible(Gadget)
Protected si.SCROLLINFO
si\cbSize = SizeOf(SCROLLINFO)
si\fMask = #SIF_ALL
If GetScrollInfo_(GadgetID(Gadget), #SB_VERT, @si)
ProcedureReturn Bool(si\nPos = (si\nMax - si\nPage))
EndIf
ProcedureReturn -1 ; failure
EndProcedure
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Re: EditorGadget auto scroll to last line ...
Code: Select all
Range.NSRange\location = Len(GetGadgetText(0))
CocoaMessage(0, GadgetID(0), "scrollRangeToVisible:@", @Range)
- Mindphazer
- Enthusiast
- Posts: 468
- Joined: Mon Sep 10, 2012 10:41 am
- Location: Savoie
Re: EditorGadget auto scroll to last line ...
Nope, same resultRASHAD wrote: Sun Sep 21, 2025 3:20 pm Hi Mindphazer
Sorry,I don't have Mac to test
But try the next it may make a differenceCode: Select all
Procedure SelectItem(gadget) SetActiveGadget(gadget) no = CountGadgetItems(gadget) AddGadgetItem(gadget,-1,"") RemoveGadgetItem(gadget, no) EndProcedure
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
...and unfortunately... Windows at work...
- Mindphazer
- Enthusiast
- Posts: 468
- Joined: Mon Sep 10, 2012 10:41 am
- Location: Savoie
Re: EditorGadget auto scroll to last line ...
I knowPiero wrote: Sun Sep 21, 2025 4:23 pmCode: Select all
Range.NSRange\location = Len(GetGadgetText(0)) CocoaMessage(0, GadgetID(0), "scrollRangeToVisible:@", @Range)
Rashad was trying to write a code without API calls
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
...and unfortunately... Windows at work...