Implemented title text editing.

This commit is contained in:
Relintai 2022-08-25 15:20:18 +02:00
parent b156d2722a
commit 1d993a21f3
5 changed files with 13 additions and 9 deletions

View File

@ -6,17 +6,17 @@
[sub_resource type="Resource" id=1] [sub_resource type="Resource" id=1]
script = ExtResource( 3 ) script = ExtResource( 3 )
text = "" text = "asdasdasd"
hsize = 1 hsize = 1
[sub_resource type="Resource" id=2] [sub_resource type="Resource" id=2]
script = ExtResource( 3 ) script = ExtResource( 3 )
text = "" text = "weqweqwe"
hsize = 1 hsize = 1
[sub_resource type="Resource" id=3] [sub_resource type="Resource" id=3]
script = ExtResource( 3 ) script = ExtResource( 3 )
text = "" text = "rtrtrtrttrtA"
hsize = 1 hsize = 1
[node name="WebServer" type="WebServerSimple"] [node name="WebServer" type="WebServerSimple"]

View File

@ -3,3 +3,6 @@ extends Resource
class_name WebPageEntry, "res://addons/web_pages/icons/icon_web_page_entry.svg" class_name WebPageEntry, "res://addons/web_pages/icons/icon_web_page_entry.svg"
func get_page_entry_class_name() -> String:
return "WebPageEntry"

View File

@ -4,3 +4,8 @@ class_name WebPageEntryTitleText, "res://addons/web_pages/icons/icon_web_page_en
export(String) var text : String export(String) var text : String
export(int) var hsize : int = 1 export(int) var hsize : int = 1
func get_page_entry_class_name() -> String:
return "WebPageEntryTitleText"

View File

@ -18,15 +18,14 @@ signal entry_delete_requested(entry)
func set_entry(entry : WebPageEntry, undo_redo : UndoRedo) -> void: func set_entry(entry : WebPageEntry, undo_redo : UndoRedo) -> void:
_entry = entry _entry = entry
var cls : String = entry.get_class() var cls : String = entry.get_page_entry_class_name()
_entry_type_label.text = cls _entry_type_label.text = cls
if cls == "WebPageEntryTitleText": if cls == "WebPageEntryTitleText":
_editor = WebPageEntryTitleTextEditor.instance() _editor = WebPageEntryTitleTextEditor.instance()
if _editor: if _editor:
_editor.undo_redo = undo_redo _editor.set_entry(entry, undo_redo)
_editor.set_entry(entry)
_main_container.add_child(_editor) _main_container.add_child(_editor)
func _on_add_button_pressed(): func _on_add_button_pressed():

View File

@ -8,15 +8,12 @@ var _line_edit : LineEdit = null
func set_entry(entry : WebPageEntryTitleText, pundo_redo : UndoRedo) -> void: func set_entry(entry : WebPageEntryTitleText, pundo_redo : UndoRedo) -> void:
undo_redo = pundo_redo undo_redo = pundo_redo
_entry = entry _entry = entry
_line_edit.text = _entry.text _line_edit.text = _entry.text
func _notification(what): func _notification(what):
if what == NOTIFICATION_INSTANCED: if what == NOTIFICATION_INSTANCED:
_line_edit = get_node("LineEdit") _line_edit = get_node("LineEdit")
_line_edit.connect("text_entered", self, "_on_line_edit") _line_edit.connect("text_entered", self, "_on_line_edit")
func _on_line_edit(text : String) -> void: func _on_line_edit(text : String) -> void: