Page 1 of 1

How to Scroll (Editor_Input = EditorGadget) to Line x ?

Posted: Sat Apr 13, 2024 5:15 pm
by vmars316
Thanks in advance :
How to Scroll (Editor_Input = EditorGadget) to Line x ?
The following code Runs fine , Except it doesn't Scroll Editor_Input .

Code: Select all

        Case Editor_Output 
;Global Editor_Input , Editor_Output , HelpButton , 
;       itemText$ , selectedItem , event = 0 , spacePosition , number$ ,
;       Editor_Input_LineNumber = 0 

    If EventGadget() = Editor_Output And EventType() = #PB_EventType_LeftClick  ; Check for left click on the ListView
        ; Get the selected item index
        selectedItem = GetGadgetState(Editor_Output) ; Assuming Editor_Output is the ID of the ListView
        If selectedItem <> -1
            ; Fetch the text of the selected item 
            itemText$ = GetGadgetItemText(Editor_Output, selectedItem)
            ; Find the position of the first space
            spacePosition = FindString(itemText$, " ", 0)
            If spacePosition <> 0
                ; Extract the number before the first space
                number$ = Left(itemText$, spacePosition - 1)
                ; Convert string number to integer
                Editor_Input_LineNumber = Val(number$) - 1  ; Convert to zero-based index if needed
                ; Scroll to the line in the Editor_Input gadget
                SetGadgetState(Editor_Input, Editor_Input_LineNumber)
                MessageRequester("Event Detected", "Left click on ListView detected on item #" + Str(selectedItem) + " - Number: " + number$ + " (" + itemText$ + ")")
            EndIf
        EndIf
    EndIf   

Re: How to Scroll (Editor_Input = EditorGadget) to Line x ?

Posted: Sat Apr 13, 2024 6:21 pm
by netmaestro
For windows:

Code: Select all

OpenWindow(0,0,0,640,480,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
EditorGadget(0,0,0,640,480)
For a = 0 To 100
  AddGadgetItem(0, a, "Line "+Str(a))
Next
SendMessage_(GadgetID(0), #EM_LINESCROLL, 0, 31)
SetGadgetState(0,31)
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow

Re: How to Scroll (Editor_Input = EditorGadget) to Line x ?

Posted: Sat Apr 13, 2024 6:48 pm
by vmars316
netmaestro , Wonderfu!!
Thanks

Re: How to Scroll (Editor_Input = EditorGadget) to Line x ?

Posted: Sun Apr 14, 2024 1:55 am
by vmars316
This code creates item lines 0 thru 5
and then creates item lines 0 thru 5 Again .

Code: Select all

; Author: Danilo (updated for PB4.00 by blbltheworm)
; Help from netmaestro 
OpenWindow(0,200,200,300,500,"Test",#PB_Window_SystemMenu) 
  ButtonGadget(125,5,5,100,29,"Click Me !") 
  EditorGadget(2,5,50,290,450) 

  Procedure ClickMe()
;    Global  
    For i = 0 To 2 
      AddGadgetItem(2,-1,"Item "+  Str(i) ) ; RSet(Str(i),4,"0")) 
      SendMessage_(GadgetID(2),#EM_LINESCROLL,1,1) 
     Delay(100) 
    Next i 
EndProcedure ; ClickMe()
    
  Repeat 
    Select WaitWindowEvent() 
      Case #PB_Event_CloseWindow : End 
      Case #PB_Event_Gadget 
        Select EventGadget() 
          Case 125 ; Button 1 
;            SetGadgetState(106,MyImage(2,40,20,Random($FFFFFF))) 
            ClickMe()
        EndSelect 
    EndSelect 
  ForEver 

How can it be modified to create item lines 0 thru 5
and then creates item lines 6 thru 10 Again ?

Thanks

Re: How to Scroll (Editor_Input = EditorGadget) to Line x ?

Posted: Sun Apr 14, 2024 7:52 am
by TassyJim
vmars316 wrote: Sun Apr 14, 2024 1:55 am This code creates item lines 0 thru 5
and then creates item lines 0 thru 5 Again .
...
How can it be modified to create item lines 0 thru 5
and then creates item lines 6 thru 10 Again ?

Thanks

Code: Select all

; Author: Danilo (updated for PB4.00 by blbltheworm)
; Help from netmaestro 
OpenWindow(0,200,200,300,500,"Test",#PB_Window_SystemMenu) 
  ButtonGadget(125,5,5,100,29,"Click Me !") 
  EditorGadget(2,5,50,290,450) 

  Procedure ClickMe()
    ;    Global  
    linecount = CountGadgetItems(2)
    For i = 0 To 2 
      AddGadgetItem(2,-1,"Item "+  Str(i+linecount) ) ; RSet(Str(i),4,"0")) 
      SendMessage_(GadgetID(2),#EM_LINESCROLL,1,1) 
     Delay(100) 
    Next i 
EndProcedure ; ClickMe()
    
  Repeat 
    Select WaitWindowEvent() 
      Case #PB_Event_CloseWindow : End 
      Case #PB_Event_Gadget 
        Select EventGadget() 
          Case 125 ; Button 1 
;            SetGadgetState(106,MyImage(2,40,20,Random($FFFFFF))) 
            ClickMe()
        EndSelect 
    EndSelect 
  ForEver 


Re: How to Scroll (Editor_Input = EditorGadget) to Line x ?

Posted: Sun Apr 14, 2024 2:27 pm
by vmars316
Thanks TassyJim , Perfect .