MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / can_drop_data_fw

Method can_drop_data_fw

editor/settings/action_map_editor.cpp:290–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290bool ActionMapEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
291 Dictionary d = p_data;
292 if (!d.has("input_type")) {
293 return false;
294 }
295
296 TreeItem *source = Object::cast_to<TreeItem>(ObjectDB::get_instance(d["source"].operator ObjectID()));
297 TreeItem *selected = action_tree->get_selected();
298
299 TreeItem *item = (p_point == Vector2(Math::INF, Math::INF)) ? selected : action_tree->get_item_at_position(p_point);
300 if (!selected || !item || item == source) {
301 return false;
302 }
303
304 // Don't allow moving an action in-between events.
305 if (d["input_type"] == "action" && item->has_meta("__event")) {
306 return false;
307 }
308
309 // Don't allow moving an event to a different action.
310 if (d["input_type"] == "event" && item->get_parent() != selected->get_parent()) {
311 return false;
312 }
313
314 return true;
315}
316
317void ActionMapEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
318 if (!can_drop_data_fw(p_point, p_data, p_from)) {

Callers

nothing calls this directly

Calls 7

ObjectIDMethod · 0.80
Vector2Function · 0.50
hasMethod · 0.45
get_selectedMethod · 0.45
get_item_at_positionMethod · 0.45
has_metaMethod · 0.45
get_parentMethod · 0.45

Tested by

no test coverage detected