Page 1 of 1

Scrolleable Area for Panel

Posted: Sat Dec 14, 2024 10:54 am
by TUGI.CH
Hi everyone.

How can I create a scrollbar when the panel is dynamically expanded by buttons and input fields?
It's the right part of this screenshot: https://blog.tugi.ch/wp-content/uploads ... /image.png

Thanks for your help! ;-)
Regards, Tugi

Re: Scrolleable Area for Panel

Posted: Sat Dec 14, 2024 12:27 pm
by infratec
There is a ScrollAreaGadget().

Switch to Panel 2 and wait 5 seconds:

Code: Select all

If OpenWindow(0, 0, 0, 322, 220, "PanelGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  PanelGadget(0, 8, 8, 306, 203)
  AddGadgetItem(0, -1, "Panel 1")
  
  PanelGadget(1, 5, 5, 290, 166)
  AddGadgetItem(1, -1, "Sub-Panel 1")
  AddGadgetItem(1, -1, "Sub-Panel 2")
  AddGadgetItem(1, -1, "Sub-Panel 3")
  CloseGadgetList()
  
  AddGadgetItem(0, -1,"Panel 2")
  ScrollAreaGadget(77, 0, 0, 300, 200, 300, 150)
  ButtonGadget(2, 10, 15, 80, 24,"Button 1")
  ButtonGadget(3, 95, 15, 80, 24,"Button 2")
  CloseGadgetList()
  
  AddWindowTimer(0, 1, 5000)
  
  Repeat
    Event = WaitWindowEvent()
    Select Event
      Case #PB_Event_CloseWindow
        Exit = #True
        
      Case #PB_Event_Timer
        If EventTimer() = 1
          Debug "Timer"
          RemoveWindowTimer(0, 1)
          OpenGadgetList(77)
          CanvasGadget(99, 10, 80, 100, 600, #PB_Canvas_Border)
          CloseGadgetList()
          SetGadgetAttribute(77, #PB_ScrollArea_InnerHeight, 700)
        EndIf
        
    EndSelect
  Until Exit
EndIf

Re: Scrolleable Area for Panel

Posted: Sat Dec 14, 2024 5:44 pm
by TUGI.CH
Thank you so much! ;-)