Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Control
- #Copyright Kris Occhipinti 01/16/2021
- #https://filmsbykris.com
- #Licensed under the GPLv3
- func _ready():
- var scrollbox = create_scrollbox()
- var vbox = create_vbox(scrollbox)
- for i in range(0,20):
- add_button(vbox,"This is a button #" + str(i+1),"res://icon.png")
- func create_scrollbox():
- var box = ScrollContainer.new()
- box.set_size(get_viewport_rect().size)
- add_child(box)
- return box
- func create_vbox(parent):
- var box = VBoxContainer.new()
- box.set_h_size_flags(3)
- parent.add_child(box)
- return box
- func add_button(parent,text,icon):
- var button = Button.new()
- button.set_h_size_flags(3)
- button.text = text
- button.set_meta("count",0)
- button.connect("pressed",self,"button_press",[button])
- button.icon = load(icon)
- parent.add_child(button)
- func button_press(button):
- var count = button.get_meta("count") + 1
- button.set_meta("count",count)
- button.text = "I've been pressed " + str(count) + " times"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement