The EditorGadget (in gtk2) is a GtkTextView which is contained inside a
GtkScrolledWindow to handle the scrolling. So you have to get the parent
of the widget returned by GadgetID(), and then you can work with the
GtkScrolledWindow related functions (here i get the vertical adjustment and change it)
Code: Select all
; Note: In the PB definitions, gdouble is defined as a structure of 2 longs,
; due to the missing double support in pre-4.00 versions. We will have
; to change this now that doubles are supported.
;
; For now, just use this redefined structure instead:
;
Structure _GtkAdjustment
parent_instance.GtkObject
lower.d
upper.d
value.d
step_increment.d
page_increment.d
page_size.d
EndStructure
#Button = 0
#Editor = 1
If OpenWindow(0, 0, 0, 400, 200, "editor scroll", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ButtonGadget(#Button, 10, 10, 150, 30, "add line")
EditorGadget(#Editor, 10, 50, 380, 140)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = #Button
AddGadgetItem(#Editor, -1, "New line: " + Str(LineCount))
LineCount + 1
; get the vertical adjustment of the scrolled window
*Adjustment._GtkAdjustment = gtk_scrolled_window_get_vadjustment_(gtk_widget_get_parent_(GadgetID(#Editor)))
; change the value to the max
*Adjustment\value = *Adjustment\upper
; notify the scrolled window of the change
gtk_adjustment_value_changed_(*Adjustment)
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
End