summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorrom <romangraef@gmail.com>2021-04-26 00:25:07 +0200
committerrom <romangraef@gmail.com>2021-04-26 00:25:14 +0200
commit926714b020a89f7a2b4db00a23156bce3e54ff9e (patch)
tree5fc125a95b0c22df465240158dfc4d2e701c4915 /components
parent100e234526cf2b9f104f37dc54e63d469a0c24be (diff)
downloadldjam48-926714b020a89f7a2b4db00a23156bce3e54ff9e.tar.gz
ldjam48-926714b020a89f7a2b4db00a23156bce3e54ff9e.tar.bz2
ldjam48-926714b020a89f7a2b4db00a23156bce3e54ff9e.zip
revert buttons
Diffstat (limited to 'components')
-rw-r--r--components/button.gd22
1 files changed, 6 insertions, 16 deletions
diff --git a/components/button.gd b/components/button.gd
index 45a3f4f..734e048 100644
--- a/components/button.gd
+++ b/components/button.gd
@@ -1,6 +1,6 @@
extends Node2D
class_name ButtonTest
-export var text = "Hello, Button" setget _text
+export var text = "Hello, Button"
# Force a fixed width if != -1
export var fixed_width = -1
signal on_click()
@@ -30,23 +30,13 @@ const right_nohover = preload("res://textures/components/button/right.png")
const right_hover = preload("res://textures/components/button/right_hover.png")
const right_press = preload("res://textures/components/button/right_press.png")
-onready var label = Label.new()
+var label
func _ready():
+ label = Label.new()
+ label.text = text
label.theme = theme
add_child(label)
- _text_changed()
-
-func _text(value):
- text = value
- if label == null:
- return
- _text_changed()
-
-func _text_changed():
- label.text = ""
- label.rect_size = Vector2(0,0)
- label.text = text
label.rect_position = -label.rect_size / 2
var width = label.rect_size.x
if fixed_width > 0:
@@ -57,8 +47,8 @@ func _text_changed():
hitbox.shape = RectangleShape2D.new()
hitbox.shape.extents.y = 32
hitbox.shape.extents.x = right.position.x + right.scale.x * BASE_WIDTH / 2
- update()
- label.update()
+
+
func _on_ButtonTest_input_event(viewport, event, shape_idx):
if not (event is InputEventMouseButton):