Skip to content

Commit

Permalink
feat: add missing 'cursor-changed' type values (#38210)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed May 15, 2023
1 parent eeb1e7d commit e7fc1a4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
18 changes: 10 additions & 8 deletions docs/api/web-contents.md
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,16 @@ Returns:
* `size` [Size](structures/size.md) (optional) - the size of the `image`.
* `hotspot` [Point](structures/point.md) (optional) - coordinates of the custom cursor's hotspot.

Emitted when the cursor's type changes. The `type` parameter can be `default`,
`crosshair`, `pointer`, `text`, `wait`, `help`, `e-resize`, `n-resize`,
`ne-resize`, `nw-resize`, `s-resize`, `se-resize`, `sw-resize`, `w-resize`,
`ns-resize`, `ew-resize`, `nesw-resize`, `nwse-resize`, `col-resize`,
`row-resize`, `m-panning`, `e-panning`, `n-panning`, `ne-panning`, `nw-panning`,
`s-panning`, `se-panning`, `sw-panning`, `w-panning`, `move`, `vertical-text`,
`cell`, `context-menu`, `alias`, `progress`, `nodrop`, `copy`, `none`,
`not-allowed`, `zoom-in`, `zoom-out`, `grab`, `grabbing` or `custom`.
Emitted when the cursor's type changes. The `type` parameter can be `pointer`,
`crosshair`, `hand`, `text`, `wait`, `help`, `e-resize`, `n-resize`, `ne-resize`,
`nw-resize`, `s-resize`, `se-resize`, `sw-resize`, `w-resize`, `ns-resize`, `ew-resize`,
`nesw-resize`, `nwse-resize`, `col-resize`, `row-resize`, `m-panning`, `m-panning-vertical`,
`m-panning-horizontal`, `e-panning`, `n-panning`, `ne-panning`, `nw-panning`, `s-panning`,
`se-panning`, `sw-panning`, `w-panning`, `move`, `vertical-text`, `cell`, `context-menu`,
`alias`, `progress`, `nodrop`, `copy`, `none`, `not-allowed`, `zoom-in`, `zoom-out`, `grab`,
`grabbing`, `custom`, `null`, `drag-drop-none`, `drag-drop-move`, `drag-drop-copy`,
`drag-drop-link`, `ns-no-resize`, `ew-no-resize`, `nesw-no-resize`, `nwse-no-resize`,
or `default`.

If the `type` parameter is `custom`, the `image` parameter will hold the custom
cursor image in a [`NativeImage`](native-image.md), and `scale`, `size` and `hotspot` will hold
Expand Down
26 changes: 24 additions & 2 deletions shell/browser/api/electron_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,11 +384,11 @@ namespace {
std::string CursorTypeToString(const ui::Cursor& cursor) {
switch (cursor.type()) {
case ui::mojom::CursorType::kPointer:
return "default";
return "pointer";
case ui::mojom::CursorType::kCross:
return "crosshair";
case ui::mojom::CursorType::kHand:
return "pointer";
return "hand";
case ui::mojom::CursorType::kIBeam:
return "text";
case ui::mojom::CursorType::kWait:
Expand Down Expand Up @@ -425,6 +425,10 @@ std::string CursorTypeToString(const ui::Cursor& cursor) {
return "row-resize";
case ui::mojom::CursorType::kMiddlePanning:
return "m-panning";
case ui::mojom::CursorType::kMiddlePanningVertical:
return "m-panning-vertical";
case ui::mojom::CursorType::kMiddlePanningHorizontal:
return "m-panning-horizontal";
case ui::mojom::CursorType::kEastPanning:
return "e-panning";
case ui::mojom::CursorType::kNorthPanning:
Expand Down Expand Up @@ -471,6 +475,24 @@ std::string CursorTypeToString(const ui::Cursor& cursor) {
return "grabbing";
case ui::mojom::CursorType::kCustom:
return "custom";
case ui::mojom::CursorType::kNull:
return "null";
case ui::mojom::CursorType::kDndNone:
return "drag-drop-none";
case ui::mojom::CursorType::kDndMove:
return "drag-drop-move";
case ui::mojom::CursorType::kDndCopy:
return "drag-drop-copy";
case ui::mojom::CursorType::kDndLink:
return "drag-drop-link";
case ui::mojom::CursorType::kNorthSouthNoResize:
return "ns-no-resize";
case ui::mojom::CursorType::kEastWestNoResize:
return "ew-no-resize";
case ui::mojom::CursorType::kNorthEastSouthWestNoResize:
return "nesw-no-resize";
case ui::mojom::CursorType::kNorthWestSouthEastNoResize:
return "nwse-no-resize";
default:
return "default";
}
Expand Down

0 comments on commit e7fc1a4

Please sign in to comment.