Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
bb024ba9
Unverified
Commit
bb024ba9
authored
Jan 16, 2020
by
Rémi Verschelde
Committed by
GitHub
Jan 16, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #35197 from asynts/asynts.disable-connect-button
Refactor (and fix) how the connect button is disabled.
parents
cd8cafc3
e564b4fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
4 deletions
+28
-4
connections_dialog.cpp
editor/connections_dialog.cpp
+27
-4
connections_dialog.h
editor/connections_dialog.h
+1
-0
No files found.
editor/connections_dialog.cpp
View file @
bb024ba9
...
...
@@ -146,7 +146,7 @@ void ConnectDialog::_tree_node_selected() {
return
;
dst_path
=
source
->
get_path_to
(
current
);
get_ok
()
->
set_disabled
(
false
);
_update_ok_enabled
(
);
}
/*
...
...
@@ -210,6 +210,27 @@ void ConnectDialog::_remove_bind() {
cdbinds
->
notify_changed
();
}
/*
* Enables or disables the connect button. The connect button is enabled if a
* node is selected and valid in the selected mode.
*/
void
ConnectDialog
::
_update_ok_enabled
()
{
Node
*
target
=
tree
->
get_selected
();
if
(
target
==
nullptr
)
{
get_ok
()
->
set_disabled
(
true
);
return
;
}
if
(
!
advanced
->
is_pressed
()
&&
target
->
get_script
().
is_null
())
{
get_ok
()
->
set_disabled
(
true
);
return
;
}
get_ok
()
->
set_disabled
(
false
);
}
void
ConnectDialog
::
_notification
(
int
p_what
)
{
if
(
p_what
==
NOTIFICATION_ENTER_TREE
)
{
...
...
@@ -225,6 +246,7 @@ void ConnectDialog::_bind_methods() {
ClassDB
::
bind_method
(
"_tree_item_activated"
,
&
ConnectDialog
::
_tree_item_activated
);
ClassDB
::
bind_method
(
"_add_bind"
,
&
ConnectDialog
::
_add_bind
);
ClassDB
::
bind_method
(
"_remove_bind"
,
&
ConnectDialog
::
_remove_bind
);
ClassDB
::
bind_method
(
"_update_ok_enabled"
,
&
ConnectDialog
::
_update_ok_enabled
);
ADD_SIGNAL
(
MethodInfo
(
"connected"
));
}
...
...
@@ -301,13 +323,12 @@ void ConnectDialog::init(Connection c, bool bEdit) {
tree
->
set_marked
(
source
,
true
);
if
(
c
.
target
)
{
get_ok
()
->
set_disabled
(
false
);
set_dst_node
(
static_cast
<
Node
*>
(
c
.
target
));
set_dst_method
(
c
.
method
);
}
else
{
get_ok
()
->
set_disabled
(
true
);
}
_update_ok_enabled
();
bool
bDeferred
=
(
c
.
flags
&
CONNECT_DEFERRED
)
==
CONNECT_DEFERRED
;
bool
bOneshot
=
(
c
.
flags
&
CONNECT_ONESHOT
)
==
CONNECT_ONESHOT
;
...
...
@@ -350,6 +371,8 @@ void ConnectDialog::_advanced_pressed() {
error_label
->
set_visible
(
!
_find_first_script
(
get_tree
()
->
get_edited_scene_root
(),
get_tree
()
->
get_edited_scene_root
()));
}
_update_ok_enabled
();
set_position
((
get_viewport_rect
().
size
-
get_custom_minimum_size
())
/
2
);
}
...
...
editor/connections_dialog.h
View file @
bb024ba9
...
...
@@ -80,6 +80,7 @@ class ConnectDialog : public ConfirmationDialog {
void
_add_bind
();
void
_remove_bind
();
void
_advanced_pressed
();
void
_update_ok_enabled
();
protected
:
void
_notification
(
int
p_what
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment