MCPcopy Create free account
hub / github.com/material-shell/material-shell / foreignEntered

Method foreignEntered

src/widget/reorderableList.ts:193–220  ·  view source on GitHub ↗
(actor: DraggableActor)

Source from the content-addressed store, hash-verified

191 }
192
193 foreignEntered(actor: DraggableActor) {
194 this.foreignActor = actor;
195 const connectCancelId = actor._draggable.connect(
196 'drag-cancelled',
197 () => {
198 if (this.placeHolder.get_parent() == this)
199 this.remove_child(this.placeHolder);
200 }
201 );
202 const connectEndId = actor._draggable.connect('drag-end', () => {
203 let placeholderIndex: number | undefined = undefined;
204 const actor = this.foreignActor;
205 assert(actor !== undefined, 'drag ended before it was started');
206
207 if (this.placeHolder.get_parent()) {
208 placeholderIndex = this.get_children().indexOf(
209 this.placeHolder
210 );
211 this.remove_child(this.placeHolder);
212 }
213 actor._draggable.disconnect(connectCancelId);
214 actor._draggable.disconnect(connectEndId);
215 delete this.foreignActor;
216 if (placeholderIndex !== undefined) {
217 this.emit('foreign-actor-inserted', actor, placeholderIndex);
218 }
219 });
220 }
221}
222
223@registerGObjectClass

Callers 1

makeActorDraggableMethod · 0.95

Calls 7

assertFunction · 0.90
connectMethod · 0.65
get_parentMethod · 0.65
remove_childMethod · 0.65
get_childrenMethod · 0.65
disconnectMethod · 0.65
emitMethod · 0.65

Tested by

no test coverage detected