Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/actions/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export class EditAction {
private registerContextMenuAction() {
const editAboveItem: ContextMenuRegistry.RegistryItem = {
displayText: 'Edit Block contents (→︎)',
preconditionFn: (scope: ContextMenuRegistry.Scope) => {
preconditionFn: (scope: ContextMenuRegistry.Scope, menuOpenEvent) => {
if (menuOpenEvent instanceof PointerEvent) return 'hidden';
const workspace = scope.block?.workspace;
if (!workspace || !this.navigation.canCurrentlyNavigate(workspace)) {
return 'disabled';
Expand Down
6 changes: 5 additions & 1 deletion src/actions/insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ export class InsertAction {
displayText: () => {
return 'Insert Block (I)';
},
preconditionFn: (scope: ContextMenuRegistry.Scope) => {
preconditionFn: (
scope: ContextMenuRegistry.Scope,
menuOpenEvent: Event,
) => {
if (menuOpenEvent instanceof PointerEvent) return 'hidden';
let block;
if (scope.focusedNode instanceof Blockly.Block) {
block = scope.focusedNode;
Expand Down
5 changes: 3 additions & 2 deletions src/actions/move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ export class MoveActions {
menuItems: ContextMenuRegistry.RegistryItem[] = [
{
displayText: 'Move Block (M)',
preconditionFn: (scope) => {
preconditionFn: (scope, menuOpenEvent) => {
const workspace = scope.block?.workspace as WorkspaceSvg | null;
if (!workspace) return 'hidden';
if (!workspace || menuOpenEvent instanceof PointerEvent)
return 'hidden';
return this.mover.canMove(workspace) ? 'enabled' : 'disabled';
},
callback: (scope) => {
Expand Down
Loading