isl-org / isl-org/Open3D

Request to add `set_on_key` for open3d.visualization.O3DVisualizer in Python

Open
#7,226 1 comment 0 reactions 0 assignees View on GitHub
feature request
Dominant language
C++
Stars
14k
Forks
2.6k
Avg merge
5d 18h
Merged PRs (30d)
6

Description

### Checklist

- [x] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [x] For Python issues, I have tested with the [latest development wheel](https://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [x] I have checked the [release documentation](https://www.open3d.org/docs/release/) and the [latest documentation](https://www.open3d.org/docs/latest/) (for `main` branch).

### Proposed new feature or change

`open3d.visualization.O3DVisualizer` is an amazing out-of-box class as it provides many built-in features, however, there's no option for developers to add custom keyboard key handling to it. It is, therefore, requested that `set_on_key` should be exposed. I believe it is simple and clutter free to include this feature as `open3d.visualization.O3DVisualizer` inherits from `open3d.visualization.gui.Window` that has SetOnKeyEvent, so adding something like following to `cpp/pybind/visualization/o3dvisualizer.cpp` under `pybind_o3dvisualizer_definitions` should work just fine:

```
.def("set_on_key", &O3DVisualizer::SetOnKeyEvent,
"Sets a callback that will be called when a key is pressed. "
"The callback will be given the key event and should return "
"True if the event was handled, or False if it was not.",
"callback"_a);
```

### References

_No response_

### Additional information

I previously only used `pip` package of Open3D, so please let me know if this solution is not ideal or against design principles of Open3D.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.