-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from Jeremi360/main
AdvancedTextLabel working better in editor
- Loading branch information
Showing
6 changed files
with
135 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 44 additions & 8 deletions
52
addons/advanced-text/examples/EditTextOnClick/EditTextOnClick.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,61 @@ | ||
extends TabContainer | ||
|
||
export(String, MULTILINE) var text := "[center][shake rate=5 level=10]**Clik to edit me**[/shake][/center]" | ||
export (NodePath) onready var label = get_node(label) | ||
export (NodePath) onready var save_button = get_node(save_button) | ||
export (NodePath) onready var m_edit = get_node(m_edit) | ||
export (NodePath) onready var button = get_node(button) | ||
export var _button: NodePath | ||
export var _edit: NodePath | ||
export var _buttons_container: NodePath | ||
export var _save_button: NodePath | ||
export var _cancel_button: NodePath | ||
|
||
var button: AdvancedTextButton | ||
var m_edit: TextEdit | ||
var buttons_container: Control | ||
var save_button: Button | ||
var cancel_button: Button | ||
|
||
|
||
func _ready(): | ||
label.markup_text = text | ||
button = get_node(_button) | ||
m_edit = get_node(_edit) | ||
buttons_container = get_node(_buttons_container) | ||
save_button = get_node(_save_button) | ||
cancel_button = get_node(_cancel_button) | ||
|
||
m_edit.text = text | ||
button.markup_text = text | ||
button.connect("pressed", self, "_on_button_pressed") | ||
save_button.connect("pressed", self, "_on_save_button_pressed") | ||
cancel_button.connect("pressed", self, "_on_cancel_button_pressed") | ||
|
||
|
||
func _on_button_pressed(): | ||
m_edit.text = button.markup_text | ||
m_edit.rect_min_size = button.rect_size | ||
current_tab = 1 | ||
buttons_container.show() | ||
|
||
|
||
func _on_save_button_pressed(): | ||
label.markup_text = m_edit.text | ||
button.markup_text = m_edit.text | ||
current_tab = 0 | ||
buttons_container.hide() | ||
|
||
|
||
func _on_cancel_button_pressed(): | ||
m_edit.text = button.markup_text | ||
current_tab = 0 | ||
buttons_container.hide() | ||
|
||
|
||
func _process(delta): | ||
if m_edit.visible: | ||
if current_tab == 1: | ||
if Input.is_key_pressed(KEY_ESCAPE): | ||
current_tab = 0 | ||
_on_cancel_button_pressed() | ||
return | ||
|
||
if Input.is_key_pressed(KEY_ENTER): | ||
if Input.is_key_pressed(KEY_MASK_SHIFT): | ||
m_edit.text += "\n" | ||
return | ||
|
||
_on_save_button_pressed() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 11 additions & 7 deletions
18
addons/advanced-text/examples/EditTextOnClickPopup/EditTextOnClickPopup.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters