How to jump to the end of a scrolled EditorGadget

Just starting out? Need help? Post your questions and find answers here.
PBExplorer12
User
User
Posts: 59
Joined: Sun Jul 21, 2013 8:30 am

How to jump to the end of a scrolled EditorGadget

Post by PBExplorer12 »

Thanks everyone for the assistance. Got one final question for the day, before taking a break -

How do you automatically point the cursor to the end of an Editor Gadget, after your program prints a lot of information on the gadget?

Currently, after the program throws lots of messages at the gadget, you can see the scroll bar, but it remains at the very top of the gadget window. So in order to see the most recent text, you have to scroll down.
User avatar
JHPJHP
Addict
Addict
Posts: 2259
Joined: Sat Oct 09, 2010 3:47 am

Re: How to jump to the end of a scrolled EditorGadget

Post by JHPJHP »

Try this:

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 50
    AddGadgetItem(0, a, "Line "+Str(a))
  Next
  SetActiveGadget(0)
  SendMessage_(GadgetID(0), #WM_KEYDOWN, #VK_END, #Null)
  SendMessage_(GadgetID(0), #WM_VSCROLL, #SB_BOTTOM, #Null)
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

If you're not investing in yourself, you're falling behind.

My PureBasic StuffFREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
PBExplorer12
User
User
Posts: 59
Joined: Sun Jul 21, 2013 8:30 am

Re: How to jump to the end of a scrolled EditorGadget

Post by PBExplorer12 »

"
SendMessage_(GadgetID(0), #WM_KEYDOWN, #VK_END, #Null)
SendMessage_(GadgetID(0), #WM_VSCROLL, #SB_BOTTOM, #Null)
"

Yep, adding


SendMessage_(GadgetID( edtOutput ), #WM_KEYDOWN, #VK_END, #Null)
SendMessage_(GadgetID( edtOutput ), #WM_VSCROLL, #SB_BOTTOM, #Null)

after every AddGadgetItem( edtOutput...) or SetGadgetText( edtOutput, sOutput )

seem to do the trick, thanks JHP. I'll go ahead and encapsulate all of it in one function.
Post Reply