MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / keyPressEvent

Method keyPressEvent

bt_editor/editor_flowscene.cpp:59–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59void EditorFlowScene::keyPressEvent(QKeyEvent *event)
60{
61
62 for( const auto& it: nodes())
63 {
64 const auto& node = it.second;
65 auto line_edits = node->nodeDataModel()->embeddedWidget()->findChildren<QLineEdit*>();
66 for(auto line_edit: line_edits )
67 {
68 if( line_edit->hasFocus() )
69 {
70 // Do not swallow the keyPressEvent, you are editing a QLineEdit
71 QGraphicsScene::keyPressEvent(event);
72 return;
73 }
74 }
75 }
76
77 const QString& registration_ID = _clipboard_node.model.registration_ID;
78
79 auto selected_items = selectedItems();
80 if( selected_items.size() == 1 &&
81 event->key() == Qt::Key_C &&
82 event->modifiers() == Qt::ControlModifier)
83 {
84 auto node_item = dynamic_cast<QtNodes::NodeGraphicsObject*>( selected_items.front() );
85 if( !node_item ) return;
86
87 QtNodes::Node& selected_node = node_item->node();
88 auto node_model = dynamic_cast<BehaviorTreeDataModel*>( selected_node.nodeDataModel() );
89 if( !node_model ) return;
90
91 _clipboard_node.model = node_model->model();
92 _clipboard_node.instance_name = node_model->instanceName();
93 }
94 else if( event->key() == Qt::Key_V &&
95 event->modifiers() == Qt::ControlModifier &&
96 registry().isRegistered( registration_ID ) )
97 {
98 auto views_ = views();
99 QGraphicsView* view = views_.front();
100 auto mouse_pos = view->viewport()->mapFromGlobal( QCursor::pos() );
101 auto scene_pos = view->mapToScene( mouse_pos );
102
103 createNodeAtPos( registration_ID,
104 _clipboard_node.instance_name,
105 scene_pos );
106 }
107 else{
108 QGraphicsScene::keyPressEvent(event);
109 }
110}
111
112
113void EditorFlowScene::dropEvent(QGraphicsSceneDragDropEvent *event)

Callers

nothing calls this directly

Calls 2

embeddedWidgetMethod · 0.80
nodeMethod · 0.80

Tested by

no test coverage detected