-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Is your feature request related to a problem? Please describe.
UI events in Blockly don’t fit the Blockly.Events.Ui pattern well.
- properties for events don’t fit the names
element,newValue, andoldValuewell - properties of Ui events cannot be typed well (for
newValueandoldValue) - for some events,
oldValuedoesn’t add any information (like in mutatorOpen, warningOpen, commentOpen) - some newer UI events, like viewport change, have multiple “new” properties (viewport coordinates and scale)
Describe the solution you'd like
Split ui events into different events, setting the type based on logical grouping and building in some other way to distinguish these events as ui events.
These events could inherit from a UI events interface and have a property isUiEvent=true and have AbstractEvent first declare this property (false by default, but true for ui events)
Current UI Events and properties:
| element | oldValue | newValue |
|---|---|---|
| dragStart | null | this.draggingBlock_.getDescendants(false) |
| dragStop | this.draggingBlock_.getDescendants(false) | null |
| selected | null or id | null or id |
| click | null | 'workspace' or 'block' |
| cursorMove | oldNode | newNode |
| markerMove | oldNode | newNode |
| commentOpen | true or false | true or false |
| mutatorOpen | true or false | true or false |
| warningOpen | true or false | true or false |
| trashcanOpen | true or false | true or false |
| category | old category name or null | new category name or null |
| theme | null | null |
New grouping of events and properties:
| class | type | properties | old ui events |
|---|---|---|---|
| Blockly.Events.BlockDrag | drag | blocks, isStart | dragStart, dragStop |
| Blockly.Events.Selected | selected | oldElementId, newElementId | select |
| Blockly.Events.Click | click | targetType | click |
| Blockly.Events.MarkerMove | marker_move | oldNode, newNode, isCursor | cursorMove, markerMove |
| Blockly.Events.BubbleOpen | bubble_open | isOpen, bubbleType | commentOpen, mutatorOpen, warningOpen |
| Blockly.Events.TrashcanOpen | trashcanOpen | isOpen | trashcanOpen |
| Blockly.Events.ToolboxItemSelect | toolbox_item_select | oldItem, newItem | category |
| Blockly.Events.ThemeChange | theme_change | themeName | theme |
| Blockly.Events.ViewportChange | viewport_change | viewTop, viewLeft, scale | zoom |
Describe alternatives you've considered
Split into different events, while still sharing the same (‘ui’) type and adding a sub-type to further distinguish the type of event. This, however, wouldn't work well with registering events and serialization/deserialization since the type is what is used for registration (and deserialization) and we can’t register multiple events with the same type.
Additional context
Viewport event #1052