Page 1 of 1

How to jump to the end of a scrolled EditorGadget

Posted: Tue Aug 20, 2013 8:25 pm
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.

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

Posted: Tue Aug 20, 2013 9:50 pm
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

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

Posted: Tue Aug 20, 2013 10:09 pm
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.