Skip to content

Commit

Permalink
🧰: prevent world menu opening from overriding custom position
Browse files Browse the repository at this point in the history
  • Loading branch information
merryman committed Oct 25, 2023
1 parent c99b5c4 commit 73eedf5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lively.ide/studio/top-bar.cp.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,18 @@ export class TopBarModel extends ViewModel {
}

shapeMenu (evt) {
const menu = $world.openWorldMenu(evt, this.getShapeMenuItems());
menu.position = this.ui.shapeModeButton.globalBounds().bottomLeft().subPt($world.scroll);
const pos = this.ui.shapeModeButton.globalBounds().bottomLeft().subPt($world.scroll);
$world.openWorldMenu(evt, this.getShapeMenuItems(), pos);
}

async saveMenu (evt) {
const menu = $world.openWorldMenu(evt, (await this.getSaveMenuItems()));
menu.position = this.ui.saveButton.globalBounds().bottomLeft().subPt($world.scroll);
const pos = this.ui.saveButton.globalBounds().bottomLeft().subPt($world.scroll);
$world.openWorldMenu(evt, (await this.getSaveMenuItems()), pos);
}

cursorMenu (evt) {
const menu = $world.openWorldMenu(evt, this.getHandAndHaloModeItems());
menu.position = this.ui.handOrHaloModeButton.globalBounds().bottomLeft().subPt($world.scroll);
const pos = this.ui.handOrHaloModeButton.globalBounds().bottomLeft().subPt($world.scroll);
$world.openWorldMenu(evt, this.getHandAndHaloModeItems(), pos);
}

cursorMode () {
Expand All @@ -209,8 +209,8 @@ export class TopBarModel extends ViewModel {
}

canvasMenu (evt) {
const menu = this.world().openWorldMenu(evt, this.getCanvasModeItems());
menu.position = this.ui.canvasModeButton.globalBounds().bottomLeft().subPt(this.world().scroll);
const pos = this.ui.canvasModeButton.globalBounds().bottomLeft().subPt(this.world().scroll);
this.world().openWorldMenu(evt, this.getCanvasModeItems(), pos);
}

onKeyUp () {
Expand Down
8 changes: 6 additions & 2 deletions lively.ide/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,13 +782,17 @@ export class LivelyWorld extends World {
return aMorph;
}

async openWorldMenu (evt, items) {
async openWorldMenu (evt, items, worldPos = false) {
const eventState = this.env.eventDispatcher.eventState;
if (eventState.menu) eventState.menu.remove();
eventState.menu = items && items.length
? Menu.openAtHand(items, { hand: (evt && evt.hand) || this.firstHand })
: null;
await eventState.menu.whenRendered();
if (worldPos) {
eventState.menu.position = worldPos;
return eventState.menu;
}
await eventState.menu.whenRendered(); // this causes weird flickering when
return this.moveIntoVisibleBounds(eventState.menu);
}

Expand Down

0 comments on commit 73eedf5

Please sign in to comment.