MCPcopy Create free account
hub / github.com/SpartanJ/eepp / createListView

Method createListView

src/tools/ecode/plugins/plugin.cpp:167–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167void Plugin::createListView( UICodeEditor* editor, std::shared_ptr<Model> model,
168 const ModelEventCallback& onModelEventCb,
169 const std::function<void( UIListView* )> onCreateCb ) {
170 UICodeEditorSplitter* splitter = getManager()->getSplitter();
171
172 if ( nullptr == splitter || !editorExists( editor ) ) {
173 if ( editor->getId().empty() )
174 return;
175
176 UISceneNode* uiSceneNode = getUISceneNode();
177 editor->runOnMainThread( [model, editor, onModelEventCb, onCreateCb, uiSceneNode] {
178 UIListView* lv = createListViewHelper( editor, model, onModelEventCb );
179 std::string id = editor->getId();
180 if ( onCreateCb )
181 onCreateCb( lv );
182 Uint32 focusCb = lv->getUISceneNode()->getUIEventDispatcher()->addFocusEventCallback(
183 [lv]( const auto&, Node* focus, Node* ) {
184 if ( !lv->inParentTreeOf( focus ) && !lv->isClosing() )
185 lv->close();
186 } );
187 Uint32 cursorCb = editor->on( Event::OnCursorPosChange,
188 [lv, editor, id, uiSceneNode]( const Event* ) {
189 if ( !lv->isClosing() ) {
190 lv->close();
191 if ( uiSceneNode->find( id ) )
192 editor->setFocus();
193 }
194 } );
195 lv->on( Event::KeyDown, [lv, uiSceneNode, editor, id]( const Event* event ) {
196 if ( event->asKeyEvent()->getKeyCode() == EE::Window::KEY_ESCAPE &&
197 !lv->isClosing() )
198 lv->close();
199 if ( uiSceneNode->find( id ) )
200 editor->setFocus();
201 } );
202 lv->on( Event::OnClose, [lv, editor, cursorCb, focusCb]( const Event* ) {
203 lv->getUISceneNode()->getUIEventDispatcher()->removeFocusEventCallback( focusCb );
204 editor->removeEventListener( cursorCb );
205 } );
206 } );
207 return;
208 }
209
210 editor->runOnMainThread( [model, editor, splitter, onModelEventCb, onCreateCb] {
211 UIListView* lv = createListViewHelper( editor, model, onModelEventCb );
212 if ( onCreateCb )
213 onCreateCb( lv );
214 Uint32 focusCb = lv->getUISceneNode()->getUIEventDispatcher()->addFocusEventCallback(
215 [lv]( const auto&, Node* focus, Node* ) {
216 if ( !lv->inParentTreeOf( focus ) && !lv->isClosing() )
217 lv->close();
218 } );
219 Uint32 cursorCb =
220 editor->on( Event::OnCursorPosChange, [lv, editor, splitter]( const Event* ) {
221 if ( !lv->isClosing() ) {
222 lv->close();
223 if ( splitter->editorExists( editor ) )
224 editor->setFocus();

Callers 1

showSlashCommandsMethod · 0.80

Calls 15

runOnMainThreadMethod · 0.80
addFocusEventCallbackMethod · 0.80
getUIEventDispatcherMethod · 0.80
inParentTreeOfMethod · 0.80
asKeyEventMethod · 0.80
getIdMethod · 0.65
closeMethod · 0.65
getSplitterMethod · 0.45
emptyMethod · 0.45
getUISceneNodeMethod · 0.45
isClosingMethod · 0.45

Tested by

no test coverage detected